Creating Graphical User Interfaces Previous page   Next Page

Design of the GUI

This GUI requires three input values:

When the user clicks the Plot button, the GUI puts these values into a MATLAB expression that is the sum of two sine function:

The GUI then calculates the FFT of x and creates two plots -- one frequency domain and one time domain.

Specifying Default Values for the Inputs

The GUI uses default values for the three inputs. This enables users to click on the Plot button and see a result as soon as the GUI is run. It also helps to indicate what values the user might enter.

To create the default values, set the String property of the edit text. The following figure shows the value set for the time vector.

property inspector showing string property highlighted

Identifying the Axes

Since there are two axes in this GUI, you must be able to specify which one you want to target when you issue the plotting commands. To do this, use the handles structure, which contains the handles of all components in the GUI.

The field name in the handles structure that contains the handle of any given component is derived from the component's Tag property. To make code more readable (and to make it easier to remember) this examples sets the Tag to descriptive names.

Tag property set to frequency axes

For example, the Tag of the axes used to display the FFT is set to frequency_axes. Therefore, within a callback, you access its handle with

Likewise, the Tag of the time axes is set to time_axes.

See Managing GUI Data with the Handles Structure for more information on the handles structure. See Plot Push Button Callback for the details of how to use the handle to specify the target axes.

GUI Option Settings

There are two GUI option settings that are particularly important for this GUI:

Proportional Resize Behavior.   Selecting Proportional as the resize behavior enables users to change the GUI to better view the plots. The components change size in proportion to the GUI figure size. This generally produces good results except when extremes of dimensions are used.

Callback Accessibility of Object Handles..   When GUIs include axes, handles should be visible from within callbacks. This enables you to use plotting commands like you would on the command line. Note that Callback is the default setting for command-line accessibility.

See Selecting GUI Options for more information.


Previous page  GUI with Multiple Axes Plot Push Button Callback Next page

© 1994-2005 The MathWorks, Inc.