Revised: find the frequency corresponding to max. magnitude in spectrum (FFT)
조회 수: 10 (최근 30일)
이전 댓글 표시
the spectrum of a message is shown as follows
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149033/image.png)
where magnitude plot of the Fourier transform for message versus frequency in Hz is seen.
how can i find the dominant frequency with the use of the command max and command freqz?
댓글 수: 0
채택된 답변
Wayne King
2012년 10월 4일
편집: Wayne King
2012년 10월 4일
Why are you calling freqz() on the frequency response???
[freq_resp,freq]=freqz(message,1,100000,22000);
[maxval,index] = max(abs(freq_resp));
freq(index)
I also question whether you should be using freqz(), That is really intended for filters where the inputs are the filter numerator and denominator coefficients.
Why not use the PSD
[Pxx,Fxx] = periodogram(message,rectwin(length(message)),length(message),22000);
[maxval,index] = max(Pxx);
Fxx(index)
추가 답변 (1개)
Wayne King
2012년 10월 4일
편집: Wayne King
2012년 10월 4일
If you are using freqz(), freqz() returns the frequency vector, so just query the max value of the absolute value of the frequency response and then use that index to find the frequency.
h = [1/sqrt(2) 1/sqrt(2)];
[H,F] = freqz(h,1);
[maxval,index] = max(abs(H));
F(index)
This example gives 0, because h is a lowpass filter with the maximum at 0 radians/sample.
freqz() takes the sampling frequency as an input argument so that you can get the frequencies in Hz.
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!