"Nezbytným krokem k tomu, abyste od života získali věci, po kterých toužíte, je rozhodnout se, co vlastně chcete."
function [] = plot_gui(cell_str)
% INPUT:
% cell_str - cell string with names of checkboxes
% OUTPUT: (after click on OK button
% selected cell_str
% Example:
% plot_gui({'choise 1','choise 2'})
h.f = figure('units','pixels','position',[400,400,300,300],...
'toolbar','none','menu','none');
for ii = 1:length(cell_str)
h.c(ii) = uicontrol('style','checkbox',...
'unit','pix',...
'position',[20 30*(ii-1)+150 200 20],...
'string',char(cell_str{ii}));
end
h.p = uicontrol('style','pushbutton','units','pixels',...
'position',[40,5,70,20],'string','OK',...
'callback',@p_call);
% Pushbutton callback
function p_call(varargin)
vals = get(h.c,'Value');
checked = find([vals{:}]);
if isempty(checked)
checked = 'none';
else
disp(cell_str(checked))
end
end
end
Reference:
http://www.mathworks.com/matlabcentral/answers/13351-dialog-with-checkboxes-in-gui
http://www.mathworks.com/matlabcentral/newsreader/view_thread/302712
.