User`s guide
13 Manage Application-Defined Data
GUI Data
Most GUIs generate or use data that is specific to the application. These
mechanisms provide a way for applications to save and re triev e data stored
with the GUI. With GUI data:
• You can access the data from within a callback routine using the
component’s handle, without needing to find the figure handle.
• Youdonotneedtocreateandmaintainahard-codednameforthedata
throughout your source code.
Use the
guidata function to manage GUI data. This function can store a
single variable as GUI data. GUI data differs from application data in that
• GUI d ata is a single variable; how ever, when defined as a structure, you
can add and remove fields.
• Application data can consist of many variables, each stored under a
separate unique name.
• You access GUI data using the
guidata function, which both stores and
retrieves GUI data.
• Whenever you use
guidata to store GUI data, it overwrites the existing
GUI data.
• Using the
getappdata, setappdata,andrmappdata functionsdoesnot
affect GUI data.
GUIdataisalwaysassociatedwiththeGUIfigure. Itisavailabletoall
callbacks of all components of the GUI. If you specify a component handle
whenyousaveorretrieveGUIdata,MATLABsoftwareautomatically
associates the data with the component’s parent figure.
GUI data can contain only one variable at any time. W riting GUI data with
a different variable overwrites the existing GUI data. For this reason, GUI
data is usually defined to be a structure to which you can add fields as you
need them.
You can access the data from w ithin a callback routine using the component’s
handle, without having to find the figure handle. If you specify a
component’s callback properties as function handles, the component handle is
13-8