matlab按钮组代码,matlab buttongroup switch case按钮组回调函数

S.fh = figure('units','pixels',...

'position',[200 250 250 200],...

'menubar','none',...

'name','GUI_41',...

'numbertitle','off',...

'resize','off',...

'closerequestfcn',{@fh_crfcn});

S.bg = uibuttongroup('units','pix',...

'pos',[20 70 210 90]);

S.SEL = 1;  % The selectedobject property of S.bg S.rd(1) = uicontrol(S.bg,...

'style','rad',...

'unit','pix',...

'position',[20 50 70 30],...

'string','Linear');

S.rd(2) = uicontrol(S.bg,...

'style','rad',...

'unit','pix',...

'position',[20 10 70 30],...

'string','Quadratic');

S.rd(3) = uicontrol(S.bg,...

'style','rad',...

'unit','pix',...

'position',[120 50 70 30],...

'string','Cubic');

S.rd(4) = uicontrol(S.bg,...

'style','rad',...

'unit','pix',...

'position',[120 10 70 30],...

'string','Quartic');

function [] = pb_call(varargin)

sel = findobj(get(S.bg,'selectedobject'));  % See BUG note in GUI_8

S.SEL = find(S.rd==sel);  % Store current radiobutton.

switch sel             case S.rd(1) % Linear                 S.RP(1:3) = 0;                 S.COL = 'r';             case S.rd(2)  % Quadratic                 S.RP(1:2) = 0;                 S.COL = 'k';             case S.rd(3)  % Cubic                 S.RP(1) = 0;                 S.COL = 'b';             case S.rd(4)  % Quartic                 S.COL = 'm';             otherwise                 % Very unlikely I think.         end