Creating Graphical User Interfaces    

Plot Push Button Callback

This GUI uses only the Plot button callback; the edit text callbacks are not needed and have been deleted from the GUI M-file. When a user clicks the Plot button, the callback performs three basic tasks - it gets user input from the edit text components, calculates data, and creates the two plots.

Getting User Input

The three edit text boxes provide a way for the user to enter values for the two frequencies and the time vector. The first task for the callback is to read these values. This involves:

The following code shows how the callback obtains the input.

Calculating Data

Once the input data has been converted to numeric form and assigned to local variables, the next step is to calculate the data needed for the plots. See the fft function for an explanation of how this is done.

Targeting Specific Axes

The final task for the callback is to actually generate the plots. This involves

The last step is necessary because many plotting commands (including plot) clear the axes before creating the graph. This means you cannot use the Property Inspector to set the XMinorTick and grid properties that are used in this example, since they are reset when the callback executes plot.

When looking at the following code listing, note how the handles structure is used to access the handle of the axes when needed.

Plot Button Code Listing


  Design of the GUI List Box Directory Reader