to determine the peak frequency in from the plot of the Fourier transform

4 visualizaciones (últimos 30 días)
a continuous-time sinusoid x(t)=10cos(267*pi*t+1.2) is sampled to x[n]=10cos(0.267*pi*n+1.2) with period Ts=0.001 and n is between 0 and 100 (including 0 and 100)
i attempted to determine the peak frequency using the following code.
A=10;
Fs=1000;
w=267*pi*(1/Fs);
p=1.2;
n=0:100;
x = A*cos(w*n+p);
N=500
[freq_response,freq_index] = freqz(x,1,N,Fs); %N is the number of samples
plot(freq_index,abs(freq_response))
abs(freq_response)
the magnitude plot of the Fourier transform for x versus frequency in Hz is seen, and the peak frequency observing the plot is near to 500. but it reuturns in the command window to be a series of numbers, so what's wrong with that?

Respuesta aceptada

Pedro Villena
Pedro Villena el 24 de Oct. de 2012
Editada: Pedro Villena el 24 de Oct. de 2012
n=0:100; %N=100
N=length(n);
Ts=0.001; %period [s]
Fs=1/Ts; %frequency [Hz]
t=(0:Ts:Ts*n(end));
A=10;
w=0.267*pi*Fs; %oscilation frequency [rad/s]
p=1.2; %phase [rad]
x=A*cos(w*t+p);
[freq_response,freq_index] = freqz(x,1,N,Fs); %N is the number of samples
pM = max(abs(freq_response)); %magnitude
pF = freq_index(abs(freq_response)==pM); %frequency
plot(freq_index,10*log10(abs(freq_response)),'b',pF,10*log10(pM),'r*')
title(sprintf('Peak Frequency = %f Hz (%.1f dB)',pF,10*log10(pM)));
xlabel('Frequency [Hz]')
ylabel('Power [dB]')
  2 comentarios
modified covariance
modified covariance el 24 de Oct. de 2012
thx again for ur corrections.
but how to determine the peak frequency given the hints to use freq_index and bs(freq_response)from the book.
Tnank you!
modified covariance
modified covariance el 24 de Oct. de 2012
cool, just found them on the plot, thank you very much!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Spectral Estimation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by