Specifications
Understanding the GUI M-File
4-7
Input and Output Arguments
The following examples illustrate various ways to call a GUI named my_gui
with different arguments. All arguments are passed to the opening function in
the GUI M-file.
• Calling
my_gui with no arguments opens my_gui.
• Calling
H = my_gui opens my_gui and returns the handle to my_gui.
• Calling
my_gui('Property', Value,...), where 'Property' is a valid
figure property, opens
my_gui using the given property-value pair. You can
call the GUI with more than one property-value pair.
For example,
my_gui('Position', [71.8 44.9 74.8 19.7]) opens the GUI
at the specified position, since
Position is a valid figure property. See the
reference page for
figure for a list of figure properties.
• Calling
my_gui('My_function', hObject, eventdata, handles,...) calls
the subfunction
My_function in the GUI M-file with the given input
arguments.
• Calling
my_gui('Key_word', Value,...), where 'Key_word' is any string
that is not a valid figure property or the name of a subfunction, creates a new
my_gui, and passes the pair 'Key_word', Value to the opening function in the
GUI M-file via
varargin.
You can use this calling syntax to pass arguments that are not figure
properties to the GUI. For example,
my_gui('Temperature', 98.6) opens
the GUI and passes the vector
['Temperature', 98.6] to the opening
function.
See “An Address Book Reader” on page 5-31 for an example that uses this
syntax. The example creates a GUI called
address_book. Calling the GUI with
the syntax
address_book('book', my_contacts) opens the GUI with the
MAT-file
my_contacts, which contains a list of names and addresses you want
to display. Note that you can use any string that is not a valid figure property
or the name of a callback in place of the string
'book'. See the reference page
for
figure for a list of figure properties.
Note If you call a GUI with multiple property value pairs, all the pairs that
correspond to valid figure properties must precede all the pairs that do not
correspond to valid figure properties in the sequence of arguments.