How do I find the two tallest peaks in my data?
20 views (last 30 days)
Show older comments
MathWorks Support Team
on 6 Nov 2019
Answered: MathWorks Support Team
on 6 Nov 2019
I load in my data and plot it as follows:
load sunspot.dat
year = sunspot(:,1);
relNums = sunspot(:,2);
How do I find just the two tallest peaks?
Accepted Answer
MathWorks Support Team
on 7 Nov 2019
To find the two shortest peaks, use the "findpeaks" function with the "SortStr" property set to descending order and "NPeaks" set to 2:
[pks,loc] = findpeaks(relNums, year, 'SortStr', 'descend', 'NPeaks', 2);
Here is the documentation for "findpeaks":
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!