MATLAB: Check box GUI and grapsh

ceck boxcondiction if

I'm back again, becouse I'm still working on my gui;
Now I've the following question:
In my gui I've placed 6 check box;
each check box if is actived shall plot a graphs;
Of course what I want is each time that I select a check box the graph shall plot data that coming from different matrix:
EX: given six matrix A1,A2,A3,A4,A5,A6
and six check box (c1,c2,c3,..c6) if for example I select c1 and c2 I want a graphs with both data;
I tried to create the condictions with a cicle 'If ' but I understood that this will be a little complicated becouse I have to consider 64 different condictions….(2 elevated to the sixth…)
is there any easiest way to do that???

Best Answer

I recommend you write 6 callbacks for each checkbox, and check the value of checkbox.
So any time a checkbox is checked it plots to your figure, and any time it is unchecked it deletes the line you referenced.
function chkbox1_Callback(guiobj,chckboxObj,varargin)
if checkbox1Obj.value == 1
guiobj.line1 = plot(X1,Y1,'Parent',guiobj.figure); % also store your line variable, figure variable under the gui object
hold on; % hold it for any other check boxes pressed.
else
delete(guiobj.line1);
end
end
Note:
While creating your uicontrol element put callback property like below to get your guiobject as first input reference in above callback. The second input will be your checkbox object.
uicontrol('Parent', guiobj.figure, 'style', 'checkbox', 'Callback', @guiobj.chkbox1_Callback);
Note2:
You should have a classdef of guiobj which has properties of figure,line1,line2,..etc.
Related Question