Matlab Guide checkbox issue
조회 수: 6 (최근 30일)
이전 댓글 표시
I am new to matlab and got into an issue.
I have problem with checkboxes in my matlab gui.i am using 3 checkboxes to produce 3 different plots(graphs) on same axes .I want the checkboxes to work in a way that when i check all three of them,i get 3 pots on same graph.But then when i uncheck one say number3,i am now able to see only data for check boxes 1 and 2 . Similarly when i uncheck both 3 and 2,now i should see data of only check box 1. I am able to get data of all three boxes at one time,but when uncheck more than 1 box,the graph doesn't go away?
Any help will be appreciated.
댓글 수: 0
채택된 답변
Image Analyst
2015년 2월 9일
Just have all three checkbox callbacks call the same function: CheckBoxChecked. Then in that function, clear everything and just plot the data you need to.
function checkbox1_Callback(hObject, eventdata, handles)
CheckBoxChecked(handles);
function checkbox2_Callback(hObject, eventdata, handles)
CheckBoxChecked(handles);
function checkbox3_Callback(hObject, eventdata, handles)
CheckBoxChecked(handles);
function CheckBoxChecked(handles)
cla('reset'); % Erase everything.
state1 = get(handles.checkbox1, 'value');
state2 = get(handles.checkbox2, 'value');
state3 = get(handles.checkbox3, 'value');
if state1
% Plot dataset 1
end
if state2
% Plot dataset 2
end
if state3
% Plot dataset 3
end
추가 답변 (1개)
Fangjun Jiang
2015년 2월 9일
f1=figure;
hold on;
h1=plot(1:10,1:10);
h2=plot(1:10,sin(1:10));
set(h2,'visible','off');
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!