How to find maximum among several local peaks?
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ying Wu
am 14 Nov. 2022
Kommentiert: Star Strider
am 14 Nov. 2022
Hi, I use findpeaks() to locate a few local maxima of a data array as the data may flucuate slightly when closing peak, like the figure below. The third peak in red box is the largest one in value, how can I just locate the thrid one among five peaks in matlab? Thanks!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 14 Nov. 2022
It would help to have the data.
If that is the maximum peak in value, it is also the maximum of the vector plotted in the image.
One way to return it and its index, if the independent variable vector is ‘v’, is simply:
[vmax, idx] = max(v)
Otherwise, iif that is not appropriate and if you know that the third peak is the one you want to return, this may work:
[pks,locs] = findpeaks(v)
peak3 = pks(3)
locs3 = locs(3)
There may be other ways to isolate it, however without the data, it is not possible to determine that.
.
2 Kommentare
Star Strider
am 14 Nov. 2022
As always, my pleasure!
If you want a specific number of maxima, rather than using findpeaks, you can use the maxk function (introduced in R2017b).
You can also use maxk with the findpeaks results.
II’m not certain which would be best, because I’m not certain what you want to do.
.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!