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

1 次查看(过去 30 天)
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.

采纳的回答

dpb
dpb 2018-9-22
编辑:dpb 2018-9-22
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by