Why does FFT show harmonics at different amplitude?
조회 수: 21 (최근 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!