How to find local maxima in plot(X,Y)?
Mostrar comentarios más antiguos
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
1 comentario
Azzi Abdelmalek
el 15 de Nov. de 2013
Why [peaks,locs] = findpeaks(Y) doesn't work ?
Respuesta aceptada
Más respuestas (2)
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
el 16 de Nov. de 2013
0 votos
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!