【发布时间】:2013-12-06 15:16:37
【问题描述】:
我已将WindowButtonMotionFcn 设置为我的回调,它绘制三个图,数据取决于鼠标位置。然而,这对于 MATLAB 来说似乎太多了,因为在移动我的鼠标一点之后,GUI 停止响应。
我使用此代码(从某人那里复制的部分):
set(handles.figure1, 'windowbuttonmotionfcn', @hover_Callback);
function hover_Callback(hObject, handles, eventdata)
inside = false;
pos = get(handles.axes1, 'currentpoint');
xlim = get(handles.axes1, 'XLim');
ylim = get(handles.axes1, 'YLim');
if (pos(1,1) > max(xlim(1), 1) && ...
pos(1,1) < xlim(2) && ...
pos(1,2) > ylim(1) && ...
pos(1,2) < ylim(2))
inside = true;
end
if ~inside
return
end
ix = round(pos(1,1));
iy = round(pos(2,2));
axes(handles.axes2); cla; plot(squeeze(t2(ix,iy,:)), squeeze(d2(ix,iy,:)));
axes(handles.axes3); cla; plot(squeeze(t3(ix,iy,:)), squeeze(d3(ix,iy,:)));
axes(handles.axes4); cla; plot(squeeze(t4(ix,iy,:)), squeeze(d4(ix,iy,:)));
这会导致我的 GUI 停止响应,但没有错误代码。如果我然后退出它并重新启动它,整个 MATLAB 将停止响应。任何人都知道会发生什么以及我该如何解决这个问题?或许是我的记忆被某种方式阻塞了?
【问题讨论】:
标签: matlab user-interface callback hover matlab-guide