2017-08-11 122 views
0

我是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 

回答

0

我與固定它:

保持(handles.axes2, '上')