User`s guide
Add Code for Components in C allbacks
If a user clicks the other radio button or one of the toggle buttons, it becomes
selected and Radio B utton 1 is dese lected. The follow ing figure show s the
result of clicking Toggle Button 2.
The button
group’s
SelectionChangeFcn callback is called whenever a
selection
is made. Its
hObject input argument contains the handle of the
selected
radiobuttonortogglebutton.
If you hav
e a button group that contains a set of radio buttons and toggle
buttons a
nd you want:
• An immed
iate action to occur when a radio button or toggle button is
selecte
d,youmustincludethecodetocontroltheradioandtogglebuttons
in the b
utton group’s
SelectionChangeFcn callback function, not in the
indivi
dual toggle button
Callback functions.
• Anothe
r component such as a push button to base its action on the
selec
tion, then that component’s
Callback callback can get the handle
of the
selected radio button or toggle button from the button group’s
Selec
tedObject
property.
Programming a Button Group
GUID
E does not automatically create
SelectionChangeFcn callback
temp
lates for you. To add a callback for a uibuttongroup in your GUI code
fil
e, select the button group in the Layout Editor, and then take either of
the
se actions:
8-43