findpeaks in a spectrum
29 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Star Strider
2020-4-30
The actual findpeaks output plot is not shown, and we do not have your data, so it is not possible to determine what findpeaks is actually returning. The findpeaks function has a number of name-value pair arguments that can be quite useful in getting the resullt you want. In this instance, I would use 'MinPeakProminence', although it might be possible to use 'MinPeakHeight' if you first detrended the baseline with the detrend function. (This will not affect your data, however it willl make life easier for findpeaks.)
You can get prominence values from findpeaks by requesting them using the current syntax:
[amplitudewaarde,frequentieamplitude,width,prominence] = findpeaks(pow2db(pxx),f);
then use the returned ‘prominence’ values for the peaks you want as a guide for setting the 'MinPeakProminence' value.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!