User`s guide

Compose and Code GUIs with Interactive Tools
5 Place your cursor between the empty brackets and type Ctrl+V,or
right-click and select Paste. Allowing for differences in coordinate values,
the statem ent looks like this one:
btn1 = uicontrol('Style','pushbutt on','String','Push Me',...
'Position',[55 253 65 25]);
Remember that rbbox returns coordinates in figure units ('pixels',inthis
example). If the default
Units valueofacomponentisnotthesameasthe
figure, specify it to be the same w he n you make the component. For example,
the default
Units of a uipanel is 'norm alized'. To sketch a uipanel position,
use code that uses figure
Units, as in the following example:
pnl1 = uipanel('Title','Inputs',.. .
'Units',get(gcf,'Units'),...
'Position',getrect)
Two MATLAB u tilities for compos ing GU Is can assist you in specifying
positions. Use
getpixelposition to obtain a position vector for a component
in units of pixels regardless of its
Units setting. The position origin is
with respect to the parent of the component or the enclosing figure. Use
setpixelposition to specify a new component position in pixels. The Units
property of the component remains unchanged after calling either of these
functions.
Align Components
“Use the align Function” on page 11-53
“Use Align Distribute Tools” on page 11-57
After you position components, they still m ight not line up perfectly. To make
final adjustments, use the
align function from the Command Window. As an
interactive alternative, use the Align Distribute tool, a GUI available from
the figure menu. The following sections describe both approaches.
Use the align Function
Use the alig n function to align user interface controls and axes. This function
enables you to line up the components vertically and horizontally. You can
11-53