繁体   English   中英

存储图形窗口中单击的数据点的坐标

[英]Store coordinates of a clicked data point from the figure window

在MATLAB中,我可以使用Data Cursor工具选择一个数据点,它将显示该点的X和Y( 见下图 )。

在此输入图像描述

是否可以等待用户单击一个点然后将此点的X坐标(或索引)存储到我的代码中的变量? 它不一定必须使用数据光标工具,我只需要一种方法来存储点击的点。

我能够使用MathWorks中记录的函数datacursormode来解决这个问题:我应该做一些更深入的挖掘。

这是我做的:

dcmObject = datacursormode;
pause
datacursormode off
cursor = getCursorInfo(dcmObject);
x = cursor.Position(1)

代码打开Data Cursor,等待用户选择一个点,然后存储光标的位置。

您可以通过以下方式从渲染图像或绘图中获取坐标:

msgbox('Click on the plot')
[x y] = ginput(1)

%%%%%%%%%%%%%%
x is the x coordinate of the click
y is the y coordinate of the click

参考


  1. 来自鼠标或光标的图形输入 ,访问2014-07-08, <http://www.mathworks.com/help/matlab/ref/ginput.html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM