Creating Graphical User Interfaces (GUI's) With Matlab: by Jeffrey A. Webb OSU Gateway Coalition Member
Creating Graphical User Interfaces (GUI's) With Matlab: by Jeffrey A. Webb OSU Gateway Coalition Member
Object Browser
(highlighted ones
have been selected)
Alignment Options
Property Editor
• Enables you to set the properties of the
components in your layout
• Provides a list of all settable properties and
displays the current value
Property Editor (cont’d)
Object Browser
(highlighted ones have
been selected)
Properties with
corresponding values
Menu Editor
• Allows menus on figures to be interactively
modified
• The Label, Tag, and Callback properties can
be modified directly on the tool
Menu Editor (cont’d)
Two Files
• A FIG-file - contains a • An M-file - contains
complete description the functions that
of the GUI figure and launch and control the
all of its children GUI and the callbacks,
(uicontrols and axes), which are defined as
as well as the values of sub-functions
all object properties
FIG-files
• Binary files created as a result of saving a
figure
• Contains a serialized figure object
– A complete description of the figure object and
all of its children
• All of the objects property values are set to
the values they were saved with when the
figure is recreated
M-files
• MATLAB generates the application M-file to
provide a framework for the program that
controls the GUI
• All code, including the callbacks, is contained in
the application M-file
– Each callback is implemented as a sub-function in
the M-file
Example - Launching a Dialog to
Confirm an Operation
• Illustrates how to display a dialog when
users attempt to close a GUI
• The purpose of the dialog is to force the
user to confirm that they really want to
proceed with the close operation
Objective of Dialog Box
• Want it to be launched by the application's
“Close” button
• Ask the user to confirm the close operation (i.e.,
respond yes or no)
• Block MATLAB execution until the user responds
• Handle the case where the user closes the dialog
from the window manager close box without
responding
Launching Dialog
• The “Close” button's callback needs to
launch a dialog that asks for confirmation of
the impending close operation
• This callback must then wait for a dialog to
return a value
– To accomplish this, the dialog's application
M-file assigns an output argument and the
“Close” button's callback waits for it to be
returned
Illustration of a Dialog Box
over a GUI Figure
Summary
• MATLAB GUI is a very powerful tool
when used correctly
• It takes a lot of experimenting with and a
good background in programming.
• Must have a good understanding of
MATLAB and be able to use the MATLAB
language and commands to create routines
Thank You!
Jeff Webb