How to detect peaks above a given threshold value?
52 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sudip Paudel
le 20 Juil 2020
Commenté : Sudip Paudel
le 22 Juil 2020
findpeaks() can detect multiple peaks if there is/are change in direction(s) even if the values are above the specified threshold (see arrows in the attached pdf file).
J=a vector;
findpeaks(J,'MinPeakHeight',Threshold);hold on;
yline(Threshold,'--','LineWidth',3);
hold off
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/334509/image.png)
4 commentaires
Réponse acceptée
Rashedur Rahman
le 20 Juil 2020
Hi Sudip.
The function 'findpeaks' can take several input arguments for finding peaks according to criteria. You can use multiple arguments to adjust your peak finding algorithm. I will suggest you to read the description of 'findpeaks'. ('https://www.mathworks.com/help/signal/ref/findpeaks.html').
Another way is to apply a filter to smoothen the signal and then apply 'findpeaks'.
0 commentaires
Plus de réponses (1)
Image Analyst
le 20 Juil 2020
Modifié(e) : Image Analyst
le 20 Juil 2020
Try flattening the signal by subtracting that red trend line. Then set the values of the signal below the threshold to zero and then call findpeaks()
smoothedSignal = movmean(signal, 101);
flattenedSignal = signal - smoothedSignal;
flattenedSignal(flattenedSignal < someThreshold) = 0;
[peakValues, indexesOfPeaks] = findpeaks(flattenedSignal);
Attach your data in a .mat file if you need more help.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/334512/image.png)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!