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!
modified covariance
modified covariance 2012 年 10 月 24 日
cool, just found them on the plot, thank you very much!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Estimation についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by