
9 Managing Application-Defined Data
9-2
Mechanisms for Managing Data
Most GUIs generate or use data that is specific to the application. This topic
describes the three mechanisms for managing application-defined data in the
GUI environment. They provide a way for applications to save and retrieve
data stored with the GUI.
• “GUI Data” on page 9-2
• “Application Data” on page 9-4
• “UserData Property” on page 9-6
The GUI data and application data mechanisms are similar but GUI data can
be simpler to use. GUIDE specifically uses GUI data to manage the
handles
structure, but you can either use the GUI data
handles structure or application
data to manage application-defined data. The
UserData property can also hold
application-defined data.
GUI Data
GUI data is managed using the guidata function. This function can store a
single variable as GUI data. It is also used to retrieve the value of that variable.
• “About GUI Data” on page 9-2
• “GUI Data in GUIDE” on page 9-3
• “Adding Fields to the handles Structure” on page 9-3
• “Changing GUI Data in an M-File Generated by GUIDE” on page 9-4
About GUI Data
GUI data is always associated with the GUI figure. It is available to all
callbacks of all components of the GUI. If you specify a component handle when
you save or retrieve GUI data, MATLAB automatically associates the data
with the component’s parent figure.
GUI data can contain only one variable at any time. Writing GUI data
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.
Commenti su questo manuale