我正在处理MATLAB GUI中的计时器对象。假设我们在GUI上有两个轴,并且在显示更新功能下,我们分别在每个轴上绘制。这里的问题是当绘图函数执行时,hObject属性会发生如下变化:在绘图执行之前:
get(hObject,'Children')
ans =
3x1 graphics array:
UIControl (startbutton)
Axes (axes1)
Axes (axes2)
绘图执行后,axis1消失。
plot(x,y,'LineWidth',1,'Marker','o','MarkerFaceColor','b','LineStyle','none')
K>> get(hObject,'Children')
ans =
3x1 graphics array:
UIControl (startbutton)
Axes
Axes (axes2)
我的代码的主要部分如下:
function test3_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.timer = timer(...
'ExecutionMode', 'fixedRate', ... % Run timer repeatedly
'Period', 3, ... % Initial period is 1 sec.
'TimerFcn', {@update_display, hObject}); % Specify callback function
guidata(hObject,handles);
function startbutton_Callback(hObject, eventdata, handles)
if strcmp(get(handles.timer, 'Running'), 'off')
start(handles.timer);
end
function update_display(obj,event,hObject)
handles = guidata(hObject);
guidata(hObject, handles);
axes(handles.axes2)
cla(handles.axes2
mapshow(x,y,'LineWidth',1,'Marker','o','MarkerFaceColor','b')
axes(handles.axes1)
plot(x,y,'LineWidth',1,'Marker','o','MarkerFaceColor','b','LineStyle','none')
guidata(hObject, handles);
因此,当计时器到达刷新时间(并执行显示更新功能)时,将绘制一个新图形,并且每个周期仅绘制更新而不是GUI上的axes1。你有什么想法,我怎么能解决这个问题? 在此先感谢:)