Using WindowButtonDownFcn in App Designer
显示 更早的评论
I'm trying to access data from a line in a UIAxes in my app I'm building in App Designer, but I'm unable to set a ButtonDownFcn for a UIAxes.
How can I access the x-coordinate of a point in a line so that I can generate a new plot whose x-limits are within a specified range of that x-value?
采纳的回答
更多回答(1 个)
Will Grant
2020-5-28
编辑:Will Grant
2020-5-28
The modern way of handling this behavior is to set an event handler on the line/surf/etc plot objects themselves.
This gets around messing with limits, testing which object fired, etc.
plot([1 2], [1 2], 'ButtonDownFcn', @(o, e) clickHandler(o, e));
OR
p = plot([1 2], [1 2]);
p.ButtonDownFcn = @(o, e) clickHandler(o, e);
function clickHandler(o, e)
...
end
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!