Matlab Guide checkbox issue
3 次查看(过去 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');
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!