COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Absolute values of fourier transform

• Email
• Follow

```Hi everybody,
I am trying to compute fourier transform of a sine signal having 5Hz and 10Hz frequencies. The length of the signal is 1000 samples (i.e. 9.99 sec @0.01 sec per sample). I am calculation fourier coefficients for 4096 samples (i.e. 40.95 sec @0.01 sec per sample). The absoulte value of the fourier coefficients are not corresponding to the values of my signal amplitude. Can anybody help me in finding out what I am doing wrong. My code is as follows:

Fs=100; %sampling frequency 100 samples per sec
N=1000; %number of samples
Ts=1/Fs; %time period of samples
TS=([0:N-1]')*Ts; %Total time duration of signal
Y5=sin(2*pi*5*TS);% 5 Hz signal
Y10=sin(2*pi*10*TS); %10 Hz signal
Y=Y5+Y10; %linear sum of two signals
F=fft(Y,4096); %fourier transform with 4096 samples
T=4096*Ts; %Time period of the signal
FREQ=[0:4095]./T; %harmonics of fourier
plot(FREQ,abs(F))

Well, according to some internet sources, I have to scale down the abs(F). The vertical scaling factor is (1/T) i.e. the fourier coefficient needs to be divided with the time period of the signal which is in our case is 40.95. But this approach is not giving abs(F)=1 at 10 and 5 Hz.

Kind regards
```
 0
Reply Jahanzeb 7/6/2010 11:43:05 AM

See related articles to this posting

```On Jul 6, 7:43=A0am, "Jahanzeb " <jazzmy2...@hotmail.com> wrote:
> Hi everybody,
> I am trying to compute fourier transform of a sine signal having 5Hz and =
10Hz frequencies. The length of the signal is 1000 samples (i.e. 9.99 sec @=
0.01 sec per sample). I am calculation fourier coefficients for 4096 sample=
s (i.e. 40.95 sec @0.01 sec per sample). The absoulte value of the fourier =
coefficients are not corresponding to the values of my signal amplitude. Ca=
n anybody help me in finding out what I am doing wrong. My code is as follo=
ws:
>
> Fs=3D100; %sampling frequency 100 samples per sec
> N=3D1000; %number of samples
> Ts=3D1/Fs; %time period of samples
> TS=3D([0:N-1]')*Ts; %Total time duration of signal
> Y5=3Dsin(2*pi*5*TS);% 5 Hz signal
> Y10=3Dsin(2*pi*10*TS); %10 Hz signal
> Y=3DY5+Y10; %linear sum of two signals
> F=3Dfft(Y,4096); %fourier transform with 4096 samples
> T=3D4096*Ts; %Time period of the signal
> FREQ=3D[0:4095]./T; %harmonics of fourier
> plot(FREQ,abs(F))
>
> Well, according to some internet sources, I have to scale down the abs(F)=
.. The vertical scaling factor is (1/T) i.e. the fourier coefficient needs t=
o be divided with the time period of the signal which is in our case is 40.=
95. But this approach is not giving abs(F)=3D1 at 10 and 5 Hz.
>
> Kind regards

1. Your total time is not an integral number of periods.
Therefore, the expected amplitutdes will not be exact.
2. You have N =3D 1000 original data points
3. You are using NFFT =3D 4096
4. The magnitudes are ~ 500 instead of 0.5.

Suggestion:

Why not vary NFFT to see what changes.
Next vary N to see what changes.
Finally, test some scaling factors based on what you
have done.

Hope this helps.

Greg

```
 0
Reply Greg 7/6/2010 12:43:23 PM

```On Jul 6, 8:43=A0am, Greg Heath <he...@alumni.brown.edu> wrote:
> On Jul 6, 7:43=A0am, "Jahanzeb " <jazzmy2...@hotmail.com> wrote:
>
>
>
>
>
> > Hi everybody,
> > I am trying to compute fourier transform of a sine signal having 5Hz an=
d 10Hz frequencies. The length of the signal is 1000 samples (i.e. 9.99 sec=
@0.01 sec per sample). I am calculation fourier coefficients for 4096 samp=
les (i.e. 40.95 sec @0.01 sec per sample). The absoulte value of the fourie=
r coefficients are not corresponding to the values of my signal amplitude. =
Can anybody help me in finding out what I am doing wrong. My code is as fol=
lows:
>
> > Fs=3D100; %sampling frequency 100 samples per sec
> > N=3D1000; %number of samples
> > Ts=3D1/Fs; %time period of samples
> > TS=3D([0:N-1]')*Ts; %Total time duration of signal
> > Y5=3Dsin(2*pi*5*TS);% 5 Hz signal
> > Y10=3Dsin(2*pi*10*TS); %10 Hz signal
> > Y=3DY5+Y10; %linear sum of two signals
> > F=3Dfft(Y,4096); %fourier transform with 4096 samples
> > T=3D4096*Ts; %Time period of the signal
> > FREQ=3D[0:4095]./T; %harmonics of fourier
> > plot(FREQ,abs(F))
>
> > Well, according to some internet sources, I have to scale down the abs(=
F). The vertical scaling factor is (1/T) i.e. the fourier coefficient needs=
to be divided with the time period of the signal which is in our case is 4=
0.95. But this approach is not giving abs(F)=3D1 at 10 and 5 Hz.
>
> > Kind regards
>
> 1. Your total time is not an integral number of periods.
> Therefore, the expected amplitutdes will not be exact.
> 2. You have N =3D 1000 original data points
> 3. You are using NFFT =3D 4096
> 4. The magnitudes are ~ 500 instead of 0.5.
>
> Suggestion:
>
> Why not vary NFFT to see what changes.
> Next vary N to see what changes.
> Finally, test some scaling factors based on what you
> have done.

P.S. Are you sure you are looking for abs(F) =3D 1?
What is the decomposition of sin into exponentials?

Hope this helps.

Greg

```
 0
Reply Greg 7/6/2010 12:46:19 PM

```"Jahanzeb " <jazzmy2000@hotmail.com> wrote in message <i0v4s9\$8dh\$1@fred.mathworks.com>...
> Hi everybody,
> I am trying to compute fourier transform of a sine signal having 5Hz and 10Hz frequencies. The length of the signal is 1000 samples (i.e. 9.99 sec @0.01 sec per sample). I am calculation fourier coefficients for 4096 samples (i.e. 40.95 sec @0.01 sec per sample). The absoulte value of the fourier coefficients are not corresponding to the values of my signal amplitude. Can anybody help me in finding out what I am doing wrong. My code is as follows:
>
> Fs=100; %sampling frequency 100 samples per sec
> N=1000; %number of samples
> Ts=1/Fs; %time period of samples
> TS=([0:N-1]')*Ts; %Total time duration of signal
> Y5=sin(2*pi*5*TS);% 5 Hz signal
> Y10=sin(2*pi*10*TS); %10 Hz signal
> Y=Y5+Y10; %linear sum of two signals
> F=fft(Y,4096); %fourier transform with 4096 samples
> T=4096*Ts; %Time period of the signal
> FREQ=[0:4095]./T; %harmonics of fourier
> plot(FREQ,abs(F))
>
>
> Well, according to some internet sources, I have to scale down the abs(F). The vertical scaling factor is (1/T) i.e. the fourier coefficient needs to be divided with the time period of the signal which is in our case is 40.95. But this approach is not giving abs(F)=1 at 10 and 5 Hz.
>
> Kind regards

Hi, I'm not sure why you need to pad. Your DFT bins are spaced 0.1 Hz apart, so both 5 and 10 hertz fall on DFT bins.

Y5=sin(2*pi*5*TS);% 5 Hz signal
Y10=sin(2*pi*10*TS); %10 Hz signal
Y=Y5+Y10; %linear sum of two signals
Ydft = fft(Y);
plot(abs(Ydft)/length(Y))

Your signal consists of 4 complex exponentials (each cosine consists of two complex exponentials) each with amplitude 1/2.

Wayne
```
 0
Reply Wayne 7/6/2010 2:08:07 PM

```"Wayne King" <wmkingty@gmail.com> wrote in message <i0vdc7\$21h\$1@fred.mathworks.com>...
> "Jahanzeb " <jazzmy2000@hotmail.com> wrote in message <i0v4s9\$8dh\$1@fred.mathworks.com>...
> > Hi everybody,
> > I am trying to compute fourier transform of a sine signal having 5Hz and 10Hz frequencies. The length of the signal is 1000 samples (i.e. 9.99 sec @0.01 sec per sample). I am calculation fourier coefficients for 4096 samples (i.e. 40.95 sec @0.01 sec per sample). The absoulte value of the fourier coefficients are not corresponding to the values of my signal amplitude. Can anybody help me in finding out what I am doing wrong. My code is as follows:
> >
> > Fs=100; %sampling frequency 100 samples per sec
> > N=1000; %number of samples
> > Ts=1/Fs; %time period of samples
> > TS=([0:N-1]')*Ts; %Total time duration of signal
> > Y5=sin(2*pi*5*TS);% 5 Hz signal
> > Y10=sin(2*pi*10*TS); %10 Hz signal
> > Y=Y5+Y10; %linear sum of two signals
> > F=fft(Y,4096); %fourier transform with 4096 samples
> > T=4096*Ts; %Time period of the signal
> > FREQ=[0:4095]./T; %harmonics of fourier
> > plot(FREQ,abs(F))
> >
> >
> > Well, according to some internet sources, I have to scale down the abs(F). The vertical scaling factor is (1/T) i.e. the fourier coefficient needs to be divided with the time period of the signal which is in our case is 40.95. But this approach is not giving abs(F)=1 at 10 and 5 Hz.
> >
> > Kind regards
>
> Hi, I'm not sure why you need to pad. Your DFT bins are spaced 0.1 Hz apart, so both 5 and 10 hertz fall on DFT bins.
>
> Y5=sin(2*pi*5*TS);% 5 Hz signal
> Y10=sin(2*pi*10*TS); %10 Hz signal
> Y=Y5+Y10; %linear sum of two signals
> Ydft = fft(Y);
>  plot(abs(Ydft)/length(Y))
>
> Your signal consists of 4 complex exponentials (each cosine consists of two complex exponentials) each with amplitude 1/2.
>
> Wayne

Hi, first of all, I would like to thanks to you all (Wayne and Greg) for the reply. I have tried some exercises with matlab to find whats going on in matlab. Well, both parameters (i.e. total time duration of the signal and number of fourier coefficients) are effecting the power spectrum of the signal. Now, in the following code the power spectrum is suggesting that we have different contribution of energy in both the frequencies (both frequencies are present through out the time duration of the signal).
Fs=100; %sampling frequency 100 samples per sec
N=4096; %number of samples
Ts=1/Fs; %time period of samples
TS=([0:N-1]')*Ts; %Toltal time duration of signal
Y5=sin(2*pi*5*TS);% 5 Hz signal
Y10=sin(2*pi*10*TS); %10 Hz signal
Y=Y5+Y10; %linear sum of two signals
F=fft(Y,4096); %fourier transform with 4096 samples
T=4096*Ts; %Time period of the signal
FREQ=[0:4095]./T; %harmonics of fourier
plot(FREQ,2*abs(F)./4096)

For me this is quite strange.  And the other point that I am thinking is that in real life may be I do not have any clue about the characterstics of the signal (i.e frequency, phase and amps). The only thing I would know is about the length of the signal in time. So then how could I estimate energies acurately if they are varying with the number of fourier coefficients (i.e. the scaling of the vertical axis is not know).

Kind regards
```
 0
Reply jazzmy2000 (2) 7/6/2010 2:29:05 PM

```On Jul 6, 10:29=A0am, "Jahanzeb " <jazzmy2...@hotmail.com> wrote:
> "Wayne King" <wmkin...@gmail.com> wrote in message <i0vdc7\$21...@fred.mat=
hworks.com>...
> > "Jahanzeb " <jazzmy2...@hotmail.com> wrote in message <i0v4s9\$8d...@fre=
d.mathworks.com>...
> > > Hi everybody,
> > > I am trying to compute fourier transform of a sine signal having 5Hz =
and 10Hz frequencies. The length of the signal is 1000 samples (i.e. 9.99 s=
ec @0.01 sec per sample). I am calculation fourier coefficients for 4096 sa=
mples (i.e. 40.95 sec @0.01 sec per sample). The absoulte value of the four=
ier coefficients are not corresponding to the values of my signal amplitude=
.. Can anybody help me in finding out what I am doing wrong. My code is as f=
ollows:
>
> > > Fs=3D100; %sampling frequency 100 samples per sec
> > > N=3D1000; %number of samples
> > > Ts=3D1/Fs; %time period of samples
> > > TS=3D([0:N-1]')*Ts; %Total time duration of signal
> > > Y5=3Dsin(2*pi*5*TS);% 5 Hz signal
> > > Y10=3Dsin(2*pi*10*TS); %10 Hz signal
> > > Y=3DY5+Y10; %linear sum of two signals
> > > F=3Dfft(Y,4096); %fourier transform with 4096 samples
> > > T=3D4096*Ts; %Time period of the signal
> > > FREQ=3D[0:4095]./T; %harmonics of fourier
> > > plot(FREQ,abs(F))
>
> > > Well, according to some internet sources, I have to scale down the ab=
s(F). The vertical scaling factor is (1/T) i.e. the fourier coefficient nee=
ds to be divided with the time period of the signal which is in our case is=
40.95. But this approach is not giving abs(F)=3D1 at 10 and 5 Hz.
>
> > > Kind regards
>
> > Hi, I'm not sure why you need to pad. Your DFT bins are spaced 0.1 Hz a=
part, so both 5 and 10 hertz fall on DFT bins.
>
> > Y5=3Dsin(2*pi*5*TS);% 5 Hz signal
> > Y10=3Dsin(2*pi*10*TS); %10 Hz signal
> > Y=3DY5+Y10; %linear sum of two signals
> > Ydft =3D fft(Y);
> > =A0plot(abs(Ydft)/length(Y))
>
> > Your signal consists of 4 complex exponentials (each cosine consists of=
two complex exponentials) each with amplitude 1/2.
>
> > Wayne
>
> Hi, first of all, I would like to thanks to you all (Wayne and Greg) for =
the reply. I have tried some exercises with matlab to find whats going on i=
n matlab. Well, both parameters (i.e. total time duration of the signal and=
number of fourier coefficients) are effecting the power spectrum of the si=
gnal. Now, in the following code the power spectrum is suggesting that we h=
ave different contribution of energy in both the frequencies (both frequenc=
ies are present through out the time duration of the signal).
> Fs=3D100; %sampling frequency 100 samples per sec
> N=3D4096; %number of samples
> Ts=3D1/Fs; %time period of samples
> TS=3D([0:N-1]')*Ts; %Toltal time duration of signal
> Y5=3Dsin(2*pi*5*TS);% 5 Hz signal
> Y10=3Dsin(2*pi*10*TS); %10 Hz signal
> Y=3DY5+Y10; %linear sum of two signals
> F=3Dfft(Y,4096); %fourier transform with 4096 samples
> T=3D4096*Ts; %Time period of the signal
> FREQ=3D[0:4095]./T; %harmonics of fourier
> plot(FREQ,2*abs(F)./4096)
>
> For me this is quite strange. =A0And the other point that I am thinking i=
s that in real life may be I do not have any clue about the characterstics =
of the signal (i.e frequency, phase and amps). The only thing I would know =
is about the length of the signal in time. So then how could I estimate ene=
rgies acurately if they are varying with the number of fourier coefficients=
(i.e. the scaling of >the vertical axis is not know).

You cannot.

You need to know the sampling rate.

Hope this helps.

Greg

```
 0
Reply heath (3990) 7/6/2010 4:37:56 PM

5 Replies
367 Views

Similar Articles

12/7/2013 2:09:30 PM
page loaded in 64139 ms. (0)