10 Lay Out a Programmatic UI
Create Figures for Programmatic UIs
In MATLAB software, a UI is a figure. Before you add components to it, create the
figure explicitly and obtain a handle for it. In the initialization section of your file, use a
statement such as the following to create the figure:
fh = figure;
where fh is the figure handle.
NoteIf you create a component when there is no figure, MATLAB creates a figure
automatically but does not return the figure handle.
When you create the figure, you can also specify properties for the figure. The most
commonly used figure properties are shown in the following table:
Property Values Description
MenuBar figure, none. Default is figure. Display or hide the MATLAB
standard menu bar menus. If none
and there are no user-created
menus, the menu bar itself is
removed.
Name String Title displayed in the figure
window. If NumberTitle is on,
this string is appended to the
figure number.
NumberTitle on, off. Default is on. Determines whether the string
'Figure n' (where n is the figure
number) is prefixed to the figure
window title specified by Name.
Position 4-element vector: [distance from
left, distance from bottom, width,
height].
Size of the UI figure and its
location relative to the lower-left
corner of the screen.
Resize on, off. Default is on. Determines if the user can resize
the figure window with the mouse.
Toolbar auto, none, figure. Default is
auto.
Display or hide the default figure
toolbar.