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

4 次查看(过去 30 天)
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?

采纳的回答

Pedro Villena
Pedro Villena 2012-10-24
编辑:Pedro Villena 2012-10-24
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 个评论
modified covariance
modified covariance 2012-10-24
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!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Estimation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by