fft of a 2 simple cos functions

조회 수: 7 (최근 30일)
deltanabla
deltanabla 2015년 1월 8일
답변: Rick Rosson 2015년 1월 9일
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