Specifications

Understanding the GUI M-File
4-3
You can retrieve the data in any other callback with the command
X = handles.current_data;
For an example of sharing data between callbacks, see “Example: Passing Data
Between Callbacks” on page 4-26.
For more information about handles, see “Managing GUI Data with the
Handles Structure” on page 4-26.
Accessing GUI Data
You can access any of the data for the GUI components from the handles
structure. For example, suppose your GUI has a pop-up menu, whose
Tag is
my_menu, containing three items, whose String properties are chocolate,
strawberry, and vanilla. You want another component in the GUI — a push
button, for example — to execute a command on the currently selected menu
item. In the callback for the push button, you can insert the command
all_choices = get(handles.my_menu, 'String')
current_choice = all_choices{get(handles.my_menu, 'Value')};
The command sets the value of current_choice to chocolate, strawberry, or
vanilla, depending on which item is currently selected in the menu.
You can also access the data for the entire GUI from the handles structure. If
the figure’s
Tag is figure1, then
handles.figure1
contains the figure’s handle. For example, you can make the GUI close itself
with the command
delete(handles.figure1)
For an example of closing a GUI with this command, look at the callback for
the
Close push button for the template described in “GUI with Axes and Menu”
on page 3-5.
Functions and Callbacks in the M-File
You can add code to the following parts of the GUI M-file:
Opening function — executes before the GUI becomes visible to the user.
Output function — outputs data to the command line, if necessary.