Specifications

Understanding the GUI M-File
4-5
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.
If the input argument is not a valid figure property, you must add code to the
opening function to make use of the argument. For an example, look at the
opening function for the modal question dialog template. The added code
enables you to open the modal dialog with the syntax
my_gui('String','Do you want to exit?')
which displays the text 'Do you want to exit' on the GUI. In this case, it is
necessary to add code to the opening function because
'String' is not a valid
figure property.
Output Function
The output function returns output arguments to the command line. This is
particularly useful if you want to return a variable to another GUI. For an
example, see “Example: Using the Modal Dialog to Confirm an Operation” on
page 4-40.
GUIDE generates the following lines of code in the output function:
% --- Outputs from this function are returned to the command line.
function varargout = my_gui_OutputFcn(hObject, eventdata,
handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
If the GUI is not blocking — in other words, if the M-file does not contain the
command
uiwait — the output is simply the handle to the GUI, which is
assigned to
handles.output in the opening function.
To make the GUI return a different output — for example, if you want it to
return the result of a user response, such as pressing a push button — do the
following:
Add the command
uiwait; to the opening function to make the M-file halt
execution until a user activates a component in the GUI.
For each component of the GUI where you expect a user response, make the
callback update the value of
handles.output, and execute uiresume.