why FFT results in high frequency range are not correct?

3 次查看(过去 30 天)
Hello All.
I am doing FFT with matlab.the time period i am doing the fft on it is 1 second and it consist of 50000 equlay spaces samples. I want to test the FFT results. so I have given an input as below which is a complex of sinosuidal waves (and I have samples it by sampling frequency of 50 KHZ)and I expect to have the frequency magnitude results as I have given in the input. the results are ok for low frequency ranges but for the higher frequency (5752 Hz and 7993 Hz) results are 5.742 and 6.423 respectively. what Is the origin of this big mistake ? how can I improve my results ?!
wave = 100*sin(2*pi*50*t)+1*sin (2*pi*123*t)+2*sin (2*pi*203*t)+3*sin(2*pi*223*t)+4*sin(2*pi*331*t)+5*sin(2*pi*2812*t)+6*sin(2*pi*5752*t)+7*sin(2*pi*7993*t);

采纳的回答

Geoff Hayes
Geoff Hayes 2014-8-25
Ali - what is the line (or lines) of code that you are using to do the FFT? What is the block size, N?
If I follow the examples from fft, then
% define the function
func = @(t)100*sin(2*pi*50*t) + 1*sin (2*pi*123*t) + 2*sin (2*pi*203*t) + ...
3*sin(2*pi*223*t) + 4*sin(2*pi*331*t) + 5*sin(2*pi*2812*t) + ...
6*sin(2*pi*5752*t) + 7*sin(2*pi*7993*t);
% set the sampling rate
Fs = 50000;
% set the block size
N = 50000;
% create the time vector
t = linspace(0,1-1/Fs,Fs);
% create the time domain data
y = func(t);
% do the fft
Y = fft(y,N);
% determine the frequencies
f = Fs/2*linspace(0,1,N/2+1);
% plot single-sided amplitude spectrum.
plot(f,abs(2*Y(1:N/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
A figure is created that clearly describes the frequency components of the input. To get the amplitudes of each frequency component, just do
% get Ym which is just the magnitude of the first N/2+1 elements
Ym = abs(Y(1:N/2+1))';
% find those whose magnitude is greater than one
[idcs] = find(Ym>1);
% display "table" of frequency vs amplitude (subtract one since
% frequencies start at 0; to get amplitude, divide by N/2 since real input)
[idcs-1 Ym(idcs)/(N/2)]
ans =
50 100
123 0.99999999999999
203 2
223 2.99999999999994
331 4.00000000000001
2812 5
5752 6.00000000000004
7993 6.99999999999998
The above is near identical to the input amplitudes.

更多回答(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