User`s guide

11 Lay Out a Programmatic GUI
CreateandRunaProgrammaticGUI
In this section...
“File Organization” on page 11-4
“File Template” on page 11-4
“Run the GUI” on page 11-5
File Organization
Typically, a G UI code file has the following ordered sections. You can help
to maintain the structure by adding com ments that name the sections when
you first create them.
1 Comments display ed in response to the MATLAB help command.
2 Initialization tasks such as data creation and any processing that is needed
to construct the components. See “Initialize a Programmatic GUI” on page
12-3 for more information.
3 Constru
ction of figure and components. For more information, see “Create
Figures
for Programmatic GUIs” on page 11-6 and “Add Components to a
Progra
mmatic GUI” on page 11-9.
4 Initialization tasks that require the components to exist, and output return.
See “Initialize a Programmatic GUI” on page 12-3 for more information.
5 Callbacks for the components. Callbacks are the routines that execute in
response to user-generated events such as mouse clicks and key strokes.
See “Write Code for Callbacks” on page 12-7 for more information.
6 Util
ity functions.
Fil
e Template
Thi
sisatemplateyoucanusetocreateaGUIcodefile:
function vararg out = mygui(varargin)
% MYGUI Brief description o f GUI.
% Comments displayed at the command line in response
11-4