fft of a 2 simple cos functions

3 次查看(过去 30 天)
Hi Folks,
I need to modify the code so that I am reporting the correct frequencies calculated from the fft
Fs=9827.2*2;
t=0:1/Fs:0.06756;
f=14.8;
f_1=1228.4;
x=cos(2*pi*t*f)+cos(2*pi*t*f_1);
nfft=664;
X=fft(x,nfft);
X = X(1:nfft/2);
mx=abs(X);
f=(0:nfft/2-1)*Fs/nfft/2;
figure(1);
plot(t,x);
title('Cosine wave Signal');
ylabel('Amplitude');
figure(2);
plot(f,mx);
title('Power Spectrum of a sine wave');
xlabel('Frequency(hz)');
ylabel('Power')
I expect to see the 2 fundamental frequencies 14.8Hz and 1228.4Hz (83*14.8) in the frequency window, however, it reports 14.8Hz and 621.9Hz( 14.8*42)instead.
Thanks

采纳的回答

Rick Rosson
Rick Rosson 2015-1-9
Replace the following line:
f=(0:nfft/2-1)*Fs/nfft/2;
with:
f=(0:nfft/2-1)*Fs/nfft;

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