Specifications

4 Programming GUIs
4-16
The preceding code performs the following operations:
Reads the image file
banner.jpg using the command imread.
Determines the size of the image file in pixels using the command
imfinfo.
Sets the width and height of the GUI to be 100 pixels greater than the
corresponding dimensions of the image file, which are stored as
info.Width
and
info.Height, respectively. The width and height of the GUI are the
third and fourth entries of the vector
position.
Displays the image in the axes using the command
image(handles.banner).
Makes the following changes to the axes properties:
- Sets
'Visible' to 'off' so that the axes are invisible
- Sets
'Units' to 'pixels' to match the units of the vector position
- Sets
'Position' to [50, 50, info.Width info.Height] to set the size of
the axes equal to that of the image file, and center the image file on the
GUI.
GUIs with Multiple Axes
If a GUI has multiple axes, you should explicitly specify which axes you want
to target when you issue plotting commands. You can do this using the
axes
command and the
handles structure. For example,
axes(handles.axes1)
makes the axes whose Tag property is axes1 the current axes, and therefore the
target for plotting commands. You can switch the current axes whenever you
want to target a different axes. See “GUI with Multiple Axes” on page 5-2 for
an example that uses two axes.