How to select the x-value of the maximum of a figure (without using ginput)?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sam
am 23 Dez. 2014
Bearbeitet: Sean de Wolski
am 23 Dez. 2014
I've got a figure (see attachment). I want to select the x-value of it's maximum. How do I do this?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Dez. 2014
I would use the max function with two output arguments, then use the index value to find the x-value:
[ymax,idx] = max(y);
xmax = x(idx);
0 Kommentare
Weitere Antworten (1)
Sean de Wolski
am 23 Dez. 2014
Bearbeitet: Sean de Wolski
am 23 Dez. 2014
You could use datacursortmode the axes 'ButtonDownFcn' or max() on the line's 'YData'. This is what I would do.
plot(rand(1,10));
hLine = findobj(gca,'type','line');
[~,idx] = max(hLine.YData)
hLine.XData(idx)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!