簡體   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