DSPRelated.com
Forums

finding frequencies and their amplitude

Started by aiman April 3, 2008
Hello,

I am working with random signal analysis in time domain. If the signal
consists of two different frequencies with two different amplitude, How
can I extract the frequencies and the amplitude.

For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10
and 5 respectively using MATLAB as follows:

clear
ts=0.001;
t=[0:ts:0.2];
x1=10*sin(2*pi*50*t);
x2=5*sin(2*pi*70*t);
x=x1+x2;

fs=1/0.001;
N1=256;
X1=abs(fft(x,N1));
F1=[0:(N1-1)]/N1*fs;

subplot(3,1,1)
plot(t,x)
subplot(3,1,3);
plot(F1,X1,'-x'), axis([0 100])

Can anybody tell me how to obtain back the magnitude ie(10 and 5)
-aiman-


On 3 Apr, 12:20, "aiman" <mni...@eleceng.adelaide.edu.au> wrote:
> Hello, > > I am working with random signal analysis in time domain. If the signal > consists of two different frequencies with two different amplitude, How > can I extract the frequencies and the amplitude. > > For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 > and 5 respectively using MATLAB as follows: > > clear > ts=0.001; > t=[0:ts:0.2]; > x1=10*sin(2*pi*50*t); > x2=5*sin(2*pi*70*t); > x=x1+x2; > > fs=1/0.001; > N1=256; > X1=abs(fft(x,N1)); > F1=[0:(N1-1)]/N1*fs; > > subplot(3,1,1) > plot(t,x) > subplot(3,1,3); > plot(F1,X1,'-x'), axis([0 100]) > > Can anybody tell me how to obtain back the magnitude ie(10 and 5)
In general, you can't. The only way to achieve that, is to design your experiment such that the frequencies of the sinusoidals are also Fourier frequencies, fn = 2*pi*k/N and the signal is prefectly free from noise. Neither condition ever happen in the real world. You have two possibilities to find estimates of the amplitudes. Either use a non-parametric spectrum estimator, which might give an impression of the aplitude but might miss the fact that this is a narrow-band sinusoidal, or use a parametric frequency estimator (MUSIC or ESPRIT) followed by an amplitude estimation stage. The parametric methods are very senistive to noise and numerical inaccuracies, though. Rune
On 3 abr, 07:20, "aiman" <mni...@eleceng.adelaide.edu.au> wrote:
> Hello, > > I am working with random signal analysis in time domain. If the signal > consists of two different frequencies with two different amplitude, How > can I extract the frequencies and the amplitude. > > For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 > and 5 respectively using MATLAB as follows: > > clear > ts=0.001; > t=[0:ts:0.2]; > x1=10*sin(2*pi*50*t); > x2=5*sin(2*pi*70*t); > x=x1+x2; > > fs=1/0.001; > N1=256; > X1=abs(fft(x,N1)); > F1=[0:(N1-1)]/N1*fs; > > subplot(3,1,1) > plot(t,x) > subplot(3,1,3); > plot(F1,X1,'-x'), axis([0 100]) > > Can anybody tell me how to obtain back the magnitude ie(10 and 5) > -aiman-
You should research abour MUSIC algorithm, MATLAB has a demo about it.
On 3 Apr, 13:17, Alfreeeeed <Alfredo.Tad...@gmail.com> wrote:
> On 3 abr, 07:20, "aiman" <mni...@eleceng.adelaide.edu.au> wrote:
> > Can anybody tell me how to obtain back the magnitude ie(10 and 5) > > -aiman- > > You should research abour MUSIC algorithm, MATLAB has a demo about it.-
Be very, very careful about using matlab to learn about MUSIC! I haven't seen the signal processing toolbox for a few years now (last time about 2004), but at that time the matlab version of MUSIC was useless. There were no order estimators incorporated in the method, and one could get the impression that amplidudes can be found from examining the pseudospectrum. I don't know if things have changed since I last saw the SP toolbox, but I would be very surprised if they have. Rune
On Apr 3, 3:20 am, "aiman" <mni...@eleceng.adelaide.edu.au> wrote:
> Hello, > > I am working with random signal analysis in time domain. If the signal > consists of two different frequencies with two different amplitude, How > can I extract the frequencies and the amplitude. > > For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 > and 5 respectively using MATLAB as follows: > > clear > ts=0.001; > t=[0:ts:0.2]; > x1=10*sin(2*pi*50*t); > x2=5*sin(2*pi*70*t); > x=x1+x2; > > fs=1/0.001; > N1=256; > X1=abs(fft(x,N1)); > F1=[0:(N1-1)]/N1*fs; > > subplot(3,1,1) > plot(t,x) > subplot(3,1,3); > plot(F1,X1,'-x'), axis([0 100]) > > Can anybody tell me how to obtain back the magnitude ie(10 and 5) > -aiman-
Your test sinusoids appear to be exactly periodic and orthogonal in the aperture length of the FFT, therefore all you may need for this one example is an appropriate scaling factor between the FFT bin magnitude and type of magnitude you desire (rms, average, peak, or ???) In general, however, if the frequencies of interest are not exactly periodic and orthogonal, or are mixed with noise, you will need to do a frequency estimation and a magnitude correction (for something sometimes called "scalloping loss") step, which are limited in expected accuracy by the relative noise levels, before scaling as appropriate for your result requirements. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M frequency estimation: http://www.nicholson.com/rhn/dsp.html
On Thu, 3 Apr 2008 09:30:04 -0700 (PDT), "Ron N." <rhnlogic@yahoo.com>
wrote:

>On Apr 3, 3:20 am, "aiman" <mni...@eleceng.adelaide.edu.au> wrote: >> Hello, >> >> I am working with random signal analysis in time domain. If the signal >> consists of two different frequencies with two different amplitude, How >> can I extract the frequencies and the amplitude. >> >> For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 >> and 5 respectively using MATLAB as follows: >> >> clear >> ts=0.001; >> t=[0:ts:0.2]; >> x1=10*sin(2*pi*50*t); >> x2=5*sin(2*pi*70*t); >> x=x1+x2; >> >> fs=1/0.001; >> N1=256; >> X1=abs(fft(x,N1)); >> F1=[0:(N1-1)]/N1*fs; >> >> subplot(3,1,1) >> plot(t,x) >> subplot(3,1,3); >> plot(F1,X1,'-x'), axis([0 100]) >> >> Can anybody tell me how to obtain back the magnitude ie(10 and 5) >> -aiman- > >Your test sinusoids appear to be exactly periodic and >orthogonal in the aperture length of the FFT, therefore all >you may need for this one example is an appropriate scaling >factor between the FFT bin magnitude and type of magnitude >you desire (rms, average, peak, or ???)
I think that happy coincidence may be an indicator that this is homework. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org
On Apr 3, 6:20&#4294967295;am, "aiman" <mni...@eleceng.adelaide.edu.au> wrote:
> Hello, > > I am working with random signal analysis in time domain. If the signal > consists of two different frequencies with two different amplitude, How > can I extract the frequencies and the amplitude. > > For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 > and 5 respectively using MATLAB as follows: > > clear > ts=0.001; > t=[0:ts:0.2]; > x1=10*sin(2*pi*50*t); > x2=5*sin(2*pi*70*t); > x=x1+x2; > > fs=1/0.001; > N1=256; > X1=abs(fft(x,N1)); > F1=[0:(N1-1)]/N1*fs; > > subplot(3,1,1) > plot(t,x) > subplot(3,1,3); > plot(F1,X1,'-x'), axis([0 100]) > > Can anybody tell me how to obtain back the magnitude ie(10 and 5) > -aiman-
One problem is that you have generated 201 data points but are doing a 256-pt FFT. In MATLAB that means the input data is effectively zero- padded up to length 256 prior to the FFT. So if you are expecting each signal to show up in a single bin as implied by Ron, they aren't going to. Dirk
On Apr 3, 12:33 pm, dbell <bellda2...@cox.net> wrote:
> On Apr 3, 6:20 am, "aiman" <mni...@eleceng.adelaide.edu.au> wrote: > > > > > Hello, > > > I am working with random signal analysis in time domain. If the signal > > consists of two different frequencies with two different amplitude, How > > can I extract the frequencies and the amplitude. > > > For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 > > and 5 respectively using MATLAB as follows: > > > clear > > ts=0.001; > > t=[0:ts:0.2]; > > x1=10*sin(2*pi*50*t); > > x2=5*sin(2*pi*70*t); > > x=x1+x2; > > > fs=1/0.001; > > N1=256; > > X1=abs(fft(x,N1)); > > F1=[0:(N1-1)]/N1*fs; > > > subplot(3,1,1) > > plot(t,x) > > subplot(3,1,3); > > plot(F1,X1,'-x'), axis([0 100]) > > > Can anybody tell me how to obtain back the magnitude ie(10 and 5) > > -aiman- > > One problem is that you have generated 201 data points but are doing a > 256-pt FFT. In MATLAB that means the input data is effectively zero- > padded up to length 256 prior to the FFT. So if you are expecting each > signal to show up in a single bin as implied by Ron, they aren't going > to.
Eh. Your right. I missed the fact that the OP changed the FFT length to something different from the data vector length. The OP will find rectangular window artifacts and thus have to use some estimation method.
On Thu, 3 Apr 2008 14:11:20 -0700 (PDT), "Ron N." <rhnlogic@yahoo.com>
wrote:

>On Apr 3, 12:33 pm, dbell <bellda2...@cox.net> wrote: >> On Apr 3, 6:20 am, "aiman" <mni...@eleceng.adelaide.edu.au> wrote: >> >> >> >> > Hello, >> >> > I am working with random signal analysis in time domain. If the signal >> > consists of two different frequencies with two different amplitude, How >> > can I extract the frequencies and the amplitude. >> >> > For example, I try to generate frequencies 50Hz and 70Hz with amplitude 10 >> > and 5 respectively using MATLAB as follows: >> >> > clear >> > ts=0.001; >> > t=[0:ts:0.2]; >> > x1=10*sin(2*pi*50*t); >> > x2=5*sin(2*pi*70*t); >> > x=x1+x2; >> >> > fs=1/0.001; >> > N1=256; >> > X1=abs(fft(x,N1)); >> > F1=[0:(N1-1)]/N1*fs; >> >> > subplot(3,1,1) >> > plot(t,x) >> > subplot(3,1,3); >> > plot(F1,X1,'-x'), axis([0 100]) >> >> > Can anybody tell me how to obtain back the magnitude ie(10 and 5) >> > -aiman- >> >> One problem is that you have generated 201 data points but are doing a >> 256-pt FFT. In MATLAB that means the input data is effectively zero- >> padded up to length 256 prior to the FFT. So if you are expecting each >> signal to show up in a single bin as implied by Ron, they aren't going >> to. > >Eh. Your right. I missed the fact that the OP changed >the FFT length to something different from the data >vector length. The OP will find rectangular window >artifacts and thus have to use some estimation method.
I missed that as well, but the problem is avoided by using a dft matched to the vector length instead of an fft. Not sure whether that fits with the assumptions for the OP or not . Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org
Hi Aiman,
This may be a step above what you are trying to do, but let me throw it
out.  

As the other posts have mentioned, the FFT has a problem in measuring the
amplitudes of sinusiods that fall between the bins in the frequency
domain. One solution is to use a "flat-top" window.  This is a window that
is applied to the data before the FFT.  It has the effect of making the
peak in the frequency domain have a flat-top over several bins, thereby
allowing the amplitude to be correctly measured.  Here's a link: 

http://www.dspguide.com/ch9/1.htm

Regards,
Steve