how to find local peaks of a power spectral density

24 views (last 30 days)
I have the power spectral density of an audio file and i need to find the frequency of all the peaks in the PSD. please help. The 4.WAV file is attached below
[y1,fs]=audioread('4.WAV');
Fs=2800;
S=y1(:,1);
S_filtered= (S);
N= length(S);
T=1/Fs;
tmax=N/Fs
t=0:T:tmax-T;
axes(hAxes1)
plot(t,S_filtered);
ylabel('Amplitude,db');
xlabel('time,s');
title('ossilogram');
handles.fs=Fs;
%СПМ
handles.nfft=handles.fs;
Nw=1024;
s=handles.fs/24;
Fmax=1400;
noverlap=512;
%window=hanning(Nw);
df=handles.fs/handles.nfft;
Nf=fix(Fmax/df);
handles.f=0:handles.fs/2;
[handles.Pxx1,handles.f]=pwelch(S_filtered,window,noverlap,handles.nfft,handles.fs);
%Спектр
figure
plot(handles.f(1:Nf),handles.Pxx1(1:Nf));
%title('Спектрограмма');
ylabel('');
xlabel();
[pks,locs] = findpeaks(handles.f,handles.Pxx1);

Answers (1)

Ameer Hamza
Ameer Hamza on 7 May 2020
You are passing the input to findpeaks in the wrong order. Correct is
[pks,locs] = findpeaks(handles.Pxx1, handles.f)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!