to determine the peak frequency in from the plot of the Fourier transform
조회 수: 5 (최근 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?
댓글 수: 0
채택된 답변
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]')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!