我正在尝试分析音频文件,因此我生成了信号的 FFT,并发现了高于某个阈值的峰值。这是代码的一部分:
%---------------------------Performing FFT--------------------------------%
for i = 2:No_of_peaks
song_seg = song(max_col(i-1):max_col(i)-1);
% song_seg = song(max_col(6):max_col(7)-1);
L = length(song_seg);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
seg_fft = fft(song_seg,NFFT);%/L;
N=5;Fst1=50;Fp1=60; Fp2=1040; Fst2=1050;
% d = fdesign.bandpass('N,Fst1,Fp1,Fp2,Fst2');
% h = design(d);
% seg_fft = filter(h, seg_fft);
% seg_fft(1) = 0;
%
f = FS/2*linspace(0,1,NFFT/2+1);
seg_fft2 = 2*abs(seg_fft(1:NFFT/2+1));
L5 = length(song_seg);
figure(1+i)
plot(f,seg_fft2)
title('Frequency spectrum of signal')
xlabel('Frequency (Hz)')
%xlim([0 2500])
ylabel('|Y(f)|')
ylim([0 300])
[points, loc] = findpeaks(seg_fft2,'MINPEAKHEIGHT',20)
end
现在我有了points
并且loc
我希望能够提取 60Hz 和 1000Hz 之间的峰值。我如何编写代码来实现它并存储峰值幅度以及相应的频率值???
提前感谢