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

조회 수: 1 (최근 30일)
Pappu Murthy
Pappu Murthy 2018년 9월 21일
댓글: Pappu Murthy 2018년 9월 23일
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에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by