How to select the x-value of the maximum of a figure (without using ginput)?
Show older comments
I've got a figure (see attachment). I want to select the x-value of it's maximum. How do I do this?
Accepted Answer
More Answers (1)
Sean de Wolski
on 23 Dec 2014
Edited: Sean de Wolski
on 23 Dec 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)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!