User`s guide

10 Examples of GUIDE GUIs
Com mand-line accessib ility: Off
GUI O ptions selecte d:
- Generate callback function prototypes
- Application allows only one instance to run
Call the GUI
You can invoke the GUI with no arguments, in which case the GUI uses the
default address book MAT-file, or you can specify an alternate MAT-file
from which the GUI reads information. In this example, the user calls the
GUI with a pair of argument s,
address_book('book', 'my_list.mat').
The first argument,
'book', is a key word that the code looks for in the
opening function. If the key word matches, the code uses the second
argument as the M AT-file for the a ddress book. Calling the GUI with this
syntax is analogous to calling it w ith a valid property -v alue pair, such as
('color', 'r ed') . However, since 'book' is not a valid figure property, the
address_book opening function provides code to recognize the pair ('book',
'my_list.mat')
.
It is not necessary to use the key word
'book'. You can program the
code file to accept just the MAT-file as an argument, using the syntax
address_book('my_list.mat'). The advantage of calling the GUI with
the p air
('book', 'my _lis t.mat') is that yo u can program the GU I to
accept other user arguments, as well as valid figure properties, using the
property-value pair syntax. The GUI c an then identify which property the
user wants to specify from the property name.
The following code show s how to program the opening function to look for the
key word
'book', and if it finds the key word, to use the MAT-file specified by
the second argument as the list of contacts.
function addres s_bo ok_OpeningFcn(hObject, eventdata,...
handles, vararg in)
% Choose default command li ne output for addre ss_book
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% User added code follows
if nargin < 4
10-84