Graphics Programs Reference
In-Depth Information
function exradio(action)
if nargin = = 0
uicontrol('Position',[200 321 90 25], ...
'String','JJJ', ...
uicontrol('Position',[200 296 90 25], ...
'String','ABC-FM', ...
uicontrol('Position',[200 271 90 25], ...
'String','SAFM', ...
uicontrol('Position',[200 246 90 25], ...
'String','5AD', ...
h = findobj('style','radiobutton');
ind = find(h~ = gco);
Calling the function exradio with no arguments draws the GUI and sets
up the callbacks. The callbacks are identical for all the buttons: they
simply call exradio with a single input argument. When any button
is clicked, the else code is executed: it first finds all the radiobuttons
and returns their handles in the vector h . Then a vector, ind , of the
elements of h that are not equal to the Current Object (got by the call
gco ) is defined. The radio button that has just been clicked on will
be the Current Object. If a radio button is pushed, its “value” toggles
between zero and one. The set command then sets the “value” property
of all the other radio buttons to zero.
34.4 Variables in GUIs
Variables in the matlab workspace are not visible to function m-files. If
you use a function m-file to implement a GUI, you often need to access
variables that won't be visible to the function unless you make them
so. To explain this, consider the example of the exclusive radio buttons
given in the last section. Suppose we want to get rid of the findobj
command in the else section of the code by putting the radio buttons'
Search WWH ::

Custom Search