Page 147 - Basics of MATLAB and Beyond
P. 147

(Try pushing the button.) The available styles are
                               >> set(h,’style’)
                               [ {pushbutton} | togglebutton | radiobutton | checkbox
                                | edit | text | slider | frame | listbox | popupmenu ]
                               The following table shows the possible uicontrol styles:





















                               (The togglebutton looks like a normal pushbutton but it stays pushed
                               until you click it again.) The appearance of these uicontrols depends on
                               the windowing system of your computer, but their behaviour in matlab
                               from one kind of computer to another is always the same.

                               34.1   Callbacks
                               You specify what happens when a uicontrol is activated by setting its
                               CallBack property. Callbacks are statements that get executed in the
                               matlab workspace (the command window) when a user interface ele-
                               ment is activated. As a simple example consider:
                               uicontrol(’String’,’Do plot’,’CallBack’,’plot(humps)’)
                               This creates a pushbutton uicontrol (the default)
                               containing the text “Do plot”.   When this
                               button is pressed with the mouse, the com-
                               mand plot(humps) is executed in the matlab
                               workspace. Try it now and you should see a plot
                               of the humps function appear.
                                  The callback string can be any matlab expression or function call.
                               The following simple GUIcreates three buttons to create a plot of sin(x),
                               cos(x), and tan(x). The buttons call the matlab function ezplot with
                               the appropriate trigonometric function as an input. The double quotes
                               ’’ produce a single quote in the callback string (see the section on
                               strings, page 74).



                               c   2000 by CRC Press LLC
   142   143   144   145   146   147   148   149   150   151   152