2014-06-07 164 views
0

早上好, 我有一個aplicattion:如何獲取當前點

set(gcf,'WindowButtonMotionFcn',{@mousecaptureLC}); 

在那裏我得到了x和y mousecaptureLC函數座標。

function mousecaptureLC(src, eventdata) 

pos = get(gca, 'CurrentPoint'); % Axes with a image - (Axes1) 
x = pos(1, 1); 
y = pos(1, 2); % its working very well 

這個值被髮送到標籤的文字在我的GUI:

hfig1 = findobj('Tag','lbl_x'); 
handles = guidata(hfig1); 
hfig2 = findobj('Tag','lbl_y'); 
handles = guidata(hfig2); 
set(handles.lbl_x, 'string', sprintf('X: %1.0f ', x)); 
set(handles.lbl_y, 'string', sprintf('Y: %1.0f ', y)); 

我需要做的:

我需要在其他軸,即(Axes2使用的x值), 實時。我想通過移動鼠標來繪製Axes2中的列圖像。

問題: 在mousecaptureLC()中,當我得到axes2的句柄時,我的運動函數開始工作。

h = gcf; 
Axes2 = findobj(h,'Tag','Axes2'); 
axes(Axes2) 

它通過單擊工作。它沒有更多的運動鼠標。

1)我試圖從標籤文本中獲取值(在側面的GUI函數中),但不是動態方式的工作。點擊工作。

有人可以幫助我嗎? 感謝

回答

0

使用繪圖功能中只有axes2的手柄工作

圖(handles.Axes2,X,Y)