Creating Graphical User Interfaces Previous page   Next Page

Adding Fields to a Data Structure

GUI data and application data are usually defined as structures to enable you to add fields as necessary. To add a field to a GUI data or application data structure:

  1. Use guidata or getappdata, as appropriate, to retrieve the data structure. If it was saved with guidata, it has no name and you must use guidata to retrieve it. If it was saved with setappdata, you must know its name and the object with which it is associated, and you must use getappdata to retrieve it.
  1. Assign a value to the new field. This adds the field to the structure. For example
  1. adds the field number_errors to the structure handles and sets it to 0.

  1. Use guidata or setappdata, as appropriate, to save the data. This example saves the handles structure using guidata.
  1. In a GUIDE-generated M-file, hObject is the handle of the object for which the callback was triggered. It is passed automatically to every callback.


Previous page  Mechanisms for Managing Data Sharing Data Among a GUI's Callbacks Next page

© 1994-2005 The MathWorks, Inc.