Borrar filtros
Borrar filtros

fft of a 2 simple cos functions

3 visualizaciones (últimos 30 días)
deltanabla
deltanabla el 8 de En. de 2015
Respondida: Rick Rosson el 9 de En. de 2015
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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by