Creating Graphical User Interfaces Previous page   Next Page

Adding Code to the Callbacks

When the GUI is completed and running, and a user clicks a user interface control, such as a push button, MATLAB executes the callback specified by the component's Callback property. In the example, the name of the Surf push button callback is surf_pushbutton_Callback. For information about the naming of callbacks see The Tag Property.

This section describes how to add the code for the callbacks.

Push Button Callbacks

Each of the push buttons creates a different type of plot using the data specified by the current selection in the pop-up menu. Their callbacks get data from the handles structure and then plot it. To add code to the surf push button callback, click surf_pushbutton_Callback in the callback pop-up menu.

adding code to the surf push button

Add the code after the comments following the function definition, as shown below:

Surf push button callback:

You can add similar code to the Mesh and Contour push button callbacks after the autogenerated code.

Add this code to the Mesh push button callback:

Add this code to the Contour push button callback:

Pop-up Menu Callback

The pop-up menu enables users to select the data to plot. Every time a user selects one of the three plots, the pop-up menu callback reads the pop-up menu Value property to determine what item is currently displayed and sets handles.current_data accordingly. Add the following code to the plot_popup_Callback after the comments following the function definition.


Previous page  Adding Code to the Opening Function Using the Object Browser to Identify Callbacks Next page

© 1994-2005 The MathWorks, Inc.