User`s guide

8 Programming a GUIDE GUI
For more information, see “Name a GUI and Its Files” on page 7-2,“Save a
GUIDE GUI” on page 7-4, and“Re name G UIs an d GU I Files” on page 7-3.
GUI Code File Structure
The GUI code file that GUID E generates is a f unction file. The nam e of the
main function is the same as the name of the code file. For example, if the
nameofthecodefileis
mygui.m, then the name of the main function is mygui.
Each callback in the file is a subfunction o f that main function.
When GUID E generates a code file, it automatically includes templates for
the most commonly used callbacks for each component. The code file also
contains initialization code, as well as an opening function callback and an
output function callback. It is your job to add code to the c omponent callbacks
for your GUI to work as you want. You can also add code to the opening
function callback and the output function callback. The GUI code file orders
functions as shown in the following table.
Section Description
Comments
Displayed at the command line in response to the
help
command. Edit comments as necessary for your GUI.
Initialization
GUIDE initialization tasks. Do not edit this code.
Opening function Performs your initia lization tasks before the GUI u ser
has a ccess to the GUI.
Output function Returns outputs to the MATLAB command line after
the opening function returns control and before control
returns to the command line.
Component and
figure callbacks
Control the behavior of the GUI figure and of
individual components. MATLAB software calls
a callback in response to a particular event for a
component or for the figure itself.
Utility/helper
functions
Perform miscellaneous functions not directly
associated with an event for the figure or a component.
8-8