findpeaks in a spectrum
Show older comments
Hello
Currently i am using the command 'findpeaks' to find local maximums in a plot as follows.
fs = 30000;
Ts = 1/fs;
t=0:Ts:10-Ts;
t=t';
perm = 4*pi*10^-7;
%calculate spectrum with command Pspectrum expressed in db
xTable = timetable(seconds(t),stroom);
[pxx,f] = pspectrum(xTable, 'Reassign',true, 'leakage',0.85);
%find local maximum with findpeaks
[amplitudewaarde,frequentieamplitude] = findpeaks(pow2db(pxx),f);
K = [amplitudewaarde,frequentieamplitude];
figure;
subplot(2,1,1)
plot(f,pow2db(pxx));
xlabel('Frequency (Hz)')
ylabel('Power Spectrum (dB)')
subplot(2,1,2)
plot(frequentieamplitude,amplitudewaarde);
xlabel('Frequency (Hz)')
ylabel('pieken(db)')

The plot above is the spectrum and the plot below is the plot with find peaks. But this is not exactly what i want. My main goal is to only get the values coherent with the red arrows. In the figure above i placed a data tip from a value that i dont want to have. unfortunate i still obtain those values as you can see in this matrix:

All those values i dont want to retrieve. THe only values i want are the values corresponding with the peaks(red arrows). Does anyone have a sugestion on how to handle this problem?
Thanks in advance
Accepted Answer
More Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!