Reputation: 427
I have a graph with five major peaks. I'd like to find the position and value of the first peak (the one furthest to the right). I have more than 100 different plots of this and the peak grows and shrinks in size in the various plots, and will need to use a for loop. I'm just stuck on determining the x and y values to a large number of significant figures using Matlab code.
Here's one of the many plots:
Upvotes: 2
Views: 173
Reputation: 9864
If you have access to Signal Processing Toolbox, findpeaks
is the function you are looking for. It can be invoked using different options including number of peaks, which can be helpful when that information is available.
Upvotes: 1
Reputation: 683
If you know for sure you're always gonna have 5 peaks I think the FileExchange function extrema
will be very helpful, see here.
This will return you the maxima (and minima if needed) in descending order, so the first elements of output zmax
and imax
are respectively the maximal value and its index, their second elements are the second maximum value and its index and so on.
In the case if the peak you need is always the smallest of the five you'll just need zmax(5)
and imax(5)
to determine the 5th biggest maximum.
Upvotes: 2