MATLAB Function Reference Previous page   Next Page
guidata

Store or retrieve GUI data

Syntax

Description

guidata(object_handle,data) stores the variable data as GUI data. If object_handle is not a figure handle, then the object's parent figure is used. data can be any MATLAB variable, but is typically a structure, which enables you to add new fields as required.

guidata can manage only one variable at any time. Subsequent calls to guidata(object_handle,data) overwrite the previously created version of GUI data.

data = guidata(object_handle) returns previously stored data, or an empty matrix if nothing has been stored.

To change the data managed by guidata:

  1. Get a copy of the data with the command data = guidata(object_handle).
  2. Make the desired changes to data.
  3. Save the changed version of data with the command guidata(object_handle,data).

guidata provides application developers with a convenient interface to a figure's application data:

guidata is particularly useful in conjunction with guihandles, which creates a structure containing the handles of all the components in a GUI.

Examples

In this example, guidata is used to save a structure on a GUI figure's application data from within the initialization section of the application M-file. This structure is initially created by guihandles and then used to save additional data as well.

You can recall the data from within a subfunction callback routine and then save the structure again:

See Also

guide, guihandles, getappdata, setappdata


Previous page  gtext guide Next page

© 1994-2005 The MathWorks, Inc.