阴谋坚持在GUI
问题描述:
我是matlab新手,需要一些gui帮助。我有两个轴箱(轴2和轴3),我使用复选标记来绘制。第一个复选框将创建两个图:axis2中的一个(x1,y1)和第三个中的第二个(x1,ht)。第二个复选框还会创建两个图:axis2中的一个(x2,y2)和第三个中的第二个(x2,ht2)。我想要坚持数字,所以如果我选择两个复选标记,axis2和axes3将包含两个图。但是,只有axes2工作。在axes3中只显示连接到最后选择的chechmark的图。阴谋坚持在GUI
请帮忙。该代码是下面:
function checkbox1_Callback(hObject, eventdata, handles)
if get(handles.checkbox1,'Value')
hold on;
handles.hCbox1Plot = plot(x1,y1,'LineWidth',2,'Color', [0 0 0],'parent',handles.axes2);
hold on;
handles.hCbox2Plot = plot(x1,ht,'LineWidth',2,'Color', [0 0 0],'parent',handles.axes3);
guidata(hObject,handles); % do this to save the updated handles structure
else
if ~isempty(handles.hCbox1Plot);
~isempty(handles.hCbox2Plot);
delete(handles.hCbox1Plot);
delete(handles.hCbox2Plot);
end
end
function checkbox2_Callback(hObject, eventdata, handles)
if get(handles.checkbox2,'Value')
hold on;
handles.hCbox3Plot = plot(x2,y2,'LineWidth',2,'Color', [1 0 0],'parent',handles.axes2);
hold on;
handles.hCbox4Plot = plot(x2,ht2,'LineWidth',2,'Color', [1 0 0],'parent',handles.axes3);
guidata(hObject,handles); % do this to save the updated handles structure
else
if ~isempty(handles.hCbox3Plot);
~isempty(handles.hCbox4Plot);
delete(handles.hCbox3Plot);
delete(handles.hCbox4Plot);
end
end
答
我与固定它:
保持(handles.axes2, '上')