2013-12-15 61 views
0

我有我的matlab项目的问题。如何在matlab中获取鼠标在我的设置轴上的位置?

(我的初始化块)

hFig = figure('Name', 'Form', 'NumberTitle', 'off'); 
set(hFig, 'PaperUnits', 'points') 
axis([0 10 0 10]); 
axis square off 

当我调用此函数

MouseCoord = get(src, 'CurrentPoint'); 

我得到鼠标的位置是不是在我的坐标(不同规模的轴,我认为在picsels)

如何让鼠标在我的设置轴[0 10 0 10]中的位置?

+0

请参阅:http://stackoverflow.com/questions/2769249/matlab-how-to-get-the-current-mouse-position-on-a-click-by-using-callbacks。这不完全是你需要的,但可能有所帮助。 –

+0

我试试这个。在这个窗口的右上角我有607x505。但我无法计算koef的比例,因为获得的数据与不同的位置不成比例。 – user3105249

+0

你在哪里叫'get'?什么是'src'? –

回答

0

尝试使用手柄直接轴:

src = get(hFig,'Children'); 
MouseCoord = get(src, 'CurrentPoint'); 
MouseCoord = MouseCoord(1,1:2); 

之所以做最后一行具有的CurrentPoint图和轴之间的不同的定义做。假设您只查看2D数据,则不需要全部输出。