Creating Graphical User Interfaces    

Adding Code to the Opening Function

To create data for the GUI to plot, add the following code to the opening function immediately after the comments following the function declaration.

The first six executable lines create the data using the MATLAB functions peaks, membrane and sinc to generate the data.

The next line, handles.current_data = handles.peaks, sets the current_data field of the handles structure equal to the data for peaks. The value of handles.current_data changes each time a user selects a different plot from the pop-up menu - see Pop-up Menu Callback.

The last line displays the surf plot for peaks, which appears when the GUI is first opened.

GUIDE automatically generates two more lines of code in the opening function, which follow the code that you add:


  Sharing Data Between Callbacks Adding Code to the Callbacks