How to find local maxima in plot(X,Y)?

Dear Matlab users,
I have two arrays of the same length: X and Y. The function
plot(X,Y)
plots the Y-values against the X-values as I wish. The graph contains remarkable local maxima, but how can I access them? Precisely, I need the Y-value of the local maximum as well as its corresponding X-value.
I am very aware of the function
[peaks,locs] = findpeaks(Y)
but findpeaks only detects peaks in the array Y, not in a "Y against X"-representation. Does anybody have an idea how to detect local maxima in a (X,Y)-plot?
Thank you in advance! Eduard

 Respuesta aceptada

Más respuestas (2)

Jan
Jan el 15 de Nov. de 2013

0 votos

The definition of "maximum" requires to specify a direction. Usually in X/Y plots this is the Y-direction. Then a peak in the Y-direction is completely independent from the X-values.
My impression is, that you either want something different from a "maximum", e.g. a convex hull, or that findpeaks is sufficient already. Btw. there are many further tools for this job in the FileExchange. Either search there or let an internet search engine do this for you.
Eduard
Eduard el 16 de Nov. de 2013

0 votos

First of all, thank you Jan Simon and meihua for your answers! At the end, peakdet did the job for me.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 15 de Nov. de 2013

Respondida:

el 16 de Nov. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by