User`s guide

1 About GUIs in MATLAB
®
Software
Ways to Build MATLAB GUIs
A M ATLAB GUI is a figure window to which you add user-operated controls.
You can select, size, and position these components as you like. Using
callbacks you can make the components d o what you want when the user
clicks or manipulates them w ith keystrokes.
You can build M ATLAB GUIs in two ways:
Use GUIDE (GUI Development Environment), an interactive GUI
construction kit.
Create code files that generate GUIs as functions or scripts (programmatic
GUI construction).
The first approach starts with a figure that you populate with components
from within a graphic layout editor. GUIDE creates an associated code file
containing callbacks for the GUI and its components. GUIDE saves both the
figure (as a FIG-file) a nd the code file. Opening either one also opens the
othertoruntheGUI.
In the second, programmatic, GUI-building approach, you create a code file
that defines all component properties and behaviors; when a user executes
the file, it creates a figure, populates it with components, and handles user
interactions. The figure is not normally saved between sessions because the
code in the file creates a new one each time it runs.
As a result, the code files of the two approaches look different. Programmatic
GUI files are generally longer, because they explicitly define every prope rty
ofthefigureanditscontrols,aswellasthecallbacks. GUIDEGUIsdefine
most of the properties within the figure itself. They store the d efinitions in
its FIG-file rat her than in its code file. The code file con tains callbacks and
other functions that initialize the GUI when it opens.
MATLAB software also provides functions that simplify the creation of
standard dialog boxes, for e xample to issue warnings or to open and save
files. The GUI-building technique you choose depends on your experience,
your preferences, and the kind of application you need the G UI to operate.
This table outlines some possibilities.
1-8