Creating Graphical User Interfaces    

If You Are Not Using a Handle Structure

If you are writing your own application M-file and are not generating a handle structure, you can still use the GUI figure's application data for storing any data that you want to pass between subfunctions. This mechanism involves:

Using the guidata Function

The guidata function provides a convenient interface to the figure's application data. It enables you to access the data without having to find the figure's handle (something that may be difficult when the handle is hidden) and avoids the need to create and maintain a hard-coded property name for the application data throughout your source code.

For example, you would set up the code similar to this.

In the initialization code:

Within a callback subfunction:

Note that, once a callback routine has begun execution, guidata can obtain the handle of the figure using gcbo (the handle of the object whose callback has been called). However, in the initialization section, no callback routine has been invoked so you cannot use gcbo. In this case, you can use the handle of the GUI figure returned by openfig.


 Managing GUI Data Application-Defined Data