How to select the x-value of the maximum of a figure (without using ginput)?
1 次查看(过去 30 天)
显示 更早的评论
I've got a figure (see attachment). I want to select the x-value of it's maximum. How do I do this?
0 个评论
采纳的回答
Star Strider
2014-12-23
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 个评论
更多回答(1 个)
Sean de Wolski
2014-12-23
编辑:Sean de Wolski
2014-12-23
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!