User`s guide

LayOuttheSimpleProgrammaticGUI
LayOuttheSimpleProgrammaticGUI
In this section...
“Create a Figure for a Programmatic GUI” on page 3-7
“Add C omponents to a P rogrammatic GUI” on page 3 -7
Create a Figure for a Programmatic GUI
In MATLAB software, a GUI is a figure. T his first step creates the figure and
positionsitonthescreen. ItalsomakestheGUIinvisiblesothattheGUI
user cannot see the components being added or initialized. When the GUI has
all its components and is initialized, the example makes it visible.
% Initialize and hide the GUI as it is being co nstructed.
f = figure('Visible','off','Pos ition',[360,500,450,285 ]);
Thecalltothefigure function uses two property/value pairs. The Position
property is a four-element vector that specifies the location of the GUI on the
screen and its size: [distance from left, distance from bottom, width, height].
Default units are pixels.
The next topic, “Add Components to a Programmatic GUI” o n page 3-7, shows
you how to add the push buttons, axes, and other components to the GUI.
Add Components to a Programmatic GUI
The example GUI has six components: three push buttons, one static text,
one pop-up menu, and one axes. Start by writing statements that add these
components to the G UI. Create the push buttons, static text, and pop-up
menu with the
uicontrol function. Use the axes func tion to create the axes.
1 Add the three push buttons to your GUI by adding these statements to your
code file following the call to
figure.
% Construct the components.
hsurf = uicontrol('S tyle ','pushbutton',...
'String','Surf','Position',[315,220 ,70,25]);
hmesh = uicontrol('S tyle ','pushbutton',...
'String','Mesh','Position',[315,180 ,70,25]);
3-7