I have a question on usage for fft to get fourier series back.

1 visualización (últimos 30 días)
Pappu Murthy
Pappu Murthy el 21 de Sept. de 2018
Comentada: Pappu Murthy el 23 de Sept. de 2018
My problem is
f = 1 + 2*sin(2.*pi*t/L) + 3.*sin(4*pi*t/L);
L = 1,
and I am dividing the peiod to 100 steps. Here is the program I use
L = 1;
Nsamples = 100;
t = linspace(0,L,Nsamples);
f = 1 + 2*sin(2.*pi*t/L)+ 3*sin(4*pi*t/L);
FF = fft(f);
NHarmonics = 3;
FFMag = abs(FF(1:NHarmonics))/Nsamples;
FFAngle = angle(FF(1:NHarmonics))*180/pi;
I expected FFMag to be 1, 2 and 3 the first three coefficients (a0, a1, and a2 of fourier series)
However, I am getting 1, 1, and 1.5 as the coefficients. they are half of the values of a1 and a2. a0 is correctly computed. I am sure i made a dumb error here but I can't figure it out. Please help and thanks in advance.

Respuesta aceptada

dpb
dpb el 22 de Sept. de 2018
Editada: dpb el 22 de Sept. de 2018
FFT returns the two-sided DFT so half the energy is in each of +ive and -ive frequencies. However, there is only one DC component so, therefore the a0 magnitude is as expected and a1, a2 are half.
...
FFMag = abs(FF(1:NHarmonics))/Nsamples;
FFMag(2:end)=2*FFMag(2:end); % magnitude for 1-sided transform

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by