Calculus5000
Calculus5000

Reputation: 427

Determine the position and value of peak

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: http://img690.imageshack.us/img690/6467/hiok.jpg

Upvotes: 2

Views: 173

Answers (2)

Mohsen Nosratinia
Mohsen Nosratinia

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

Fraukje
Fraukje

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

Related Questions