2012-04-05 108 views
0

我有GUI一個複選框,繪製一個矩形上的實況視頻,但是,我需要的矩形dissapear或刪除時,我取消它。 沒有人有任何想法如何做到這一點?Matlab的複選框GUI

這是我的代碼,我試圖把事情的人,但沒有任何工程。

function Box(hObject,eventdata) 

if (((get(hObject,'Value') == get(hObject,'Max')))) 
% Checkbox is checked-take appropriate action 
hold on; 
rectangle('Position',[50,50,100,100],'EdgeColor','r') 
else 
end 

回答

0

您需要保存由函數矩形創建的句柄。讓你能夠有訪問它一旦回調再次調用該句柄然後添加到您的GUI的大手柄。

所以修改,像這樣

function Box(hObject,eventdata,handles) 

if (((get(hObject,'Value') == get(hObject,'Max')))) 
% Checkbox is checked-take appropriate action 
hold on; 
handles.rectangleSave=rectangle('Position',[50,50,100,100],'EdgeColor','r'); 
guidata(handles.output,handles); 
else 
delete(handles.rectangleSave); 
end 

的功能。如果你從未使用過的手柄,請看看這裏: http://www.matlabtips.com/on-handles-and-the-door-they-open/

handles.output通常手柄存儲的大界面窗口的解釋這裏: http://www.matlabtips.com/guide-me-in-the-guide/