Creating Graphical User Interfaces    

Adding Code to the Callbacks

When the GUI is completed and running, and a user clicks a component of the GUI, MATLAB executes the callback specified by the component's Callback property. The name of the callback is determined by the component's tag property. For example, the callback for the Surf push button is surf_pushbutton_Callback.

The following 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.

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.


  Adding Code to the Opening Function Using the Object Browser to Identify Callbacks