How to use this CurrentPoint property?
32 次查看(过去 30 天)
显示 更早的评论
How to create a program that creates an axes object and that plots a line connecting the locations of successive mouse clicks within the axes. Using the waitforbuttonpress function to wait for mouse clicks and update the plot after each click. Terminate the plot when a keyboard press occurs.
0 个评论
采纳的回答
Ameer Hamza
2020-4-19
编辑:Ameer Hamza
2020-4-19
Run this example
f = figure(); % create figure and get its handle
ax = axes(); % create axes and get its handle
xlim([0 1]); % set limits of axes
ylim([0 1]);
hold on; % hold the axes so that the xlim and ylim does not change.
l = line(0, 0); % create an empty line
l.XData = [];
l.YData = [];
while waitforbuttonpress == 0
point = ax.CurrentPoint(1, 1:2); % get coordinate of current point
l.XData = [l.XData point(1)]; % add the current point to the line l
l.YData = [l.YData point(2)];
end
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!