Creating Graphical User Interfaces | ![]() ![]() |
When MATLAB creates a graph, the figure and axes are included in the list of children of their respective parents and their handles are available through commands such as findobj
, set
, and get
. If you issue another plotting command, the output is directed to the current figure and axes.
GUIs are also created in figure windows. Generally, you do not want GUI figures to be available as targets for graphics output, since issuing a plotting command could direct the output to the GUI figure, resulting in the graph appearing in the middle of the GUI.
In contrast, if you create a GUI that contains an axes, such as a plotting tool, users need access to the figure. In this case, you should enable command-line access.
Access Options
The GUIDE Application Options dialog provides three options to control user access:
HandleVisibility
and IntegerHandle
properties.Using findobj
When you set the Command-line accessibility to off
, the handle of the GUI figure is hidden. This means you cannot use findobj
to located the handles of the uicontrols in the GUI. As an alternative, the application M-file creates a object handle structure that contains the handles of each uicontrol in the GUI and passes this structure to subfunctions.
Figure Properties That Control Access
There are two figure properties that control command-line accessibility of the figure:
HandleVisibility
- determines whether the figure's handle is visible to commands that attempt to access the current figure.IntegerHandle
- determines if a figure's handle is an integer or a floating point value. Setting the HandleVisibility
property to off
removes the handle of the figure from the list of root object children so it will not become the current figure (which is the target for graphics output). The handle remains valid, however, so a command that specifies the handle explicitly still works (such as close(1)
).
Setting the IntegerHandle
property to off
causes MATLAB to assign nonreusable real-number handles (e.g., 67.0001221) instead of integers. This greatly reduces the likelihood of someone accidently performing an operation on the figure.
![]() | User-Specified Resize Operation | Electing to Generate Only the FIG-File | ![]() |