Why does FFT show harmonics at different amplitude?
32 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a signal contains fundamental + second harmonic + third + .. up to eighth harmonics. But all harmonics have same amplitude. After fft transformation, matlab shows each harmonics in different amplitudes. I was expecting them to have same amplitude. What is the reason behind it?
I want to calculate THD of the signal. But first I have to get correct amplitudes after FFT. How can I compensate the difference?
Code like that:
N = 1024; %%we need 1024 point fft
fs = 976; %%sampling frequency of the system
fb = 50; %%fundamental frequency 50 Hz
t = linspace(0,N/fs,N);
x = 0.3*cos(2*pi*fb*t)+ ...
0.3*cos(2*pi*2*fb*t)+ ...
0.3*cos(2*pi*3*fb*t)+ ...
0.3*cos(2*pi*4*fb*t)+ ...
0.3*cos(2*pi*5*fb*t)+ ...
0.3*cos(2*pi*6*fb*t)+ ...
0.3*cos(2*pi*7*fb*t)+ ...
0.3*cos(2*pi*8*fb*t);
fft_x = fft(x);
plot((0:N-1)*fs/N, abs(fft_x));
axis([0 N/2 min(abs(fft_x)) max(abs(fft_x))]);
Thanks.
0 件のコメント
採用された回答
Wayne King
2011 年 8 月 21 日
Did you change the t vector?
Fs = 976;
N = 976;
fb = 50;
t = 0:1/Fs:1-(1/Fs);
x = cos(2*pi*50*t)+cos(4*pi*50*t)+cos(6*pi*50*t);
xdft = fft(x,N);
plot(abs(xdft));
0 件のコメント
その他の回答 (6 件)
Wayne King
2011 年 8 月 21 日
Hi, Your problem is that your frequencies are not falling directly on DFT bins. The DFT bins are multiples of Fs/N.
Also, your original time vector did not reflect your sampling rate of 976 Hz. You do not incorporate zero-padding in the time vector. The way you have done it, you changed the sampling rate of the signal.
N = 976; fs = 976; %% sampling frequency of the system fb = 50; %% fundamental frequency 50 Hz t = 0:1/fs:1-(1/fs); x = 0.3*cos(2*pi*fb*t)+ ... 0.3*cos(2*pi*2*fb*t)+ ... 0.3*cos(2*pi*3*fb*t)+ ... 0.3*cos(2*pi*4*fb*t)+ ... 0.3*cos(2*pi*5*fb*t)+ ... 0.3*cos(2*pi*6*fb*t)+ ... 0.3*cos(2*pi*7*fb*t)+ ... 0.3*cos(2*pi*8*fb*t); fft_x = fft(x,N); plot((0:N-1)*fs/N, abs(fft_x));
Wayne
0 件のコメント
zohar
2011 年 8 月 21 日
Hi
When you are using
t = linspace(0,N/fs ,N);
your fs is not as you assumed it's
1/(t(2)-t(1))
just change the lines
fs = N; %%sampling frequency of the system
t = linspace(0,N/fs - 1/fs,N);
and it's ok
And that is because of you are using linspace, for next time use
t = [0:N-1]/fs;
Have fun
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!