Geoscience Reference
In-Depth Information
of these functions are those with a
graphical user interface
(GUI). A GUI in
MATLAB is a graphical display in one or more windows containing controls
(or components) that enable the user to perform interactive tasks without
typing commands in the Command Window or writing a script in the Editor.
h ese components include pull-down menus, push buttons, sliders, text input
i elds and more. h e GUI can read and write data i les as well as performing
many types of computation and displaying the results in graphics.
h e manual entitled
MATLAB Creating Graphical User Interfaces
(MathWorks 2014b) provides a comprehensive guide to the creation of
GUIs with MATLAB. Within this manual, however, the section on
Create
a Simple GUIDE GUI
demonstrates a rather complex example with many
interactive elements instead of providing the simplest possible example of a
GUI. h e following text therefore provides a very simple example of a GUI
that computes and displays a Gaussian function for a mean and a standard
deviation that can be dei ned by the user. Creating such a simple GUI with
MATLAB requires two steps: the i rst step involves designing the layout of
the GUI, and the second step involves adding functions to the components
of the GUI. h e best way to create a graphical user interface with MATLAB
is using the
GUI Design Environment
(GUIDE). We start GUIDE by typing
guide
in the Command Window. Calling GUIDE opens the
GUIDE Quick Start
dialog where we can choose to open a previously created GUI or create a new
one from a template. From the dialog we choose the GUIDE template
Blank
GUI (Default)
and click
OK
, at er which the
GUIDE Layout Editor
starts.
First, we enable
Show names in component palette
in the
GUIDE Preferences
under the
File
menu and click
OK
. Second, we select
Grid and Rulers
from
the
To o l s
menu and enable
Show rulers
. h e
GUIDE Layout Editor
displays
an empty layout with dimensions of 670-by-388 pixels. We resize the layout
to 500-by-300 pixels by clicking and dragging the lower right corner of the
GUI.
Next, we place components such as static text, edit text, and axes onto the
GUI by choosing the corresponding controls from the component palette. In
our example we place two
Edit Text
areas on the let side of the GUI, along
with a
Static Text
area containing the title
Mean
, with
Standard Deviation
above it. Double clicking the static text areas, the
Property Inspector
comes
up in which we can modify the properties of the components. We change the
String
of the static text areas to
Mean
and
Standard Deviation
. We can also
change other properties, such as the
FontName
,
FontSize
,
BackgroundColor
,
and
HorizontalAlignment
of the text. Instead of the default
Edit Text
content