MATLAB Creating Graphical User Interfaces

(ff) #1
Explicitly changing the Position or OuterPosition causes the other property to
change. For example, this is the current Position value of f:

f.Position

ans =

258 132 560 420

Changing the OuterPosition causes the Position to change:

f.OuterPosition = [250 250 490 340];
f.Position

ans =

258 258 474 248

Other UI components, such as uicontrols, uitables, and uipanels have a Position
property, which you can use to set their location and size.

Units of Measure

The default units associated with the Position property depend on the component you
are placing. However, you can change the Units property to lay out your UI in the units
of your choice. There are six different units of measure to choose from: inches,
centimeters, normalized, points, pixels, and characters.

Always specify Units before Position for the most predictable results.

f = figure('Units','inches','Position',[4 3 6 5]);

Your choice of units can affect the appearance and resizing behavior of the UI:


  • If you want the UI components to scale proportionally with the figure when the user
    resizes the figure, set the Units property of the components to 'normalized'.

  • UI Components do not scale proportionally inside the figure when their Units
    property is set to 'inches', 'centimeters', 'points', 'pixels', or
    'characters'.

  • If you are developing a cross-platform UI, then set the Units property to 'points'
    or 'characters' to make the layout consistent across all platforms.


9 Lay Out a Programmatic UI

Free download pdf