MATLAB: Revised: find the frequency corresponding to max. magnitude in spectrum (FFT)

command freqzcommand max

the spectrum of a message is shown as follows
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?

Best Answer

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)
Related Question