I have a question on usage for fft to get fourier series back.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
dpb
il 22 Set 2018
Modificato: dpb
il 22 Set 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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!