homofreq.m

来自「this program deals with homomorphic anal」· M 代码 · 共 24 行

M
24
字号
function homoFreq(x,Fs,nfft)
% x is input signal
% nfft is number of fft points

Fs = 10e3;%sampling rate
% subplot(2,1,1),plot(x);
% title('Waveform'), xlabel('Time (ms)'), ylabel('Amplitude');

Y=fft(x.*hamming(length(x)),nfft); %nfft point fft
freqAxis=Fs/2*length(Y)/Fs;
f=(0:freqAxis)*Fs/length(Y);
% subplot(2,1,2);
spec = 20*log10(abs(Y(1:length(f))));
plot(f,spec);ylim([-50 35]);
title('Spectrum'), xlabel('Frequency'),ylabel('Log Magnitude');
[pks,locs] = findpeaks(spec);
for m = 5:5, 
    differ(m-4) = locs(m)-locs(m-1); 
    %finding the difference between 5th...
    %and 4th peak of the spectrum    
end
pitchFreq = mean(differ)*Fs/nfft;
fprintf('Pitch Frequency in Frequency Domain = %gHz\n', pitchFreq);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?