User`s guide

Create the Simple Programmatic GUI Code File
Create the Simple Programmatic GUI Code File
Start by creating a file for the example GUI. Because the file will contain
functions, it is a function file as opposed to a script file, which contains a
sequence of MATLAB commands but does not define functions.
1 At the MATLAB prompt, type edit. M ATLAB opens a blank do cument in
the Editor.
2 Type or copy the following statement into the editor. This funct ion
statement is the first line in the file.
function si
mple_gui2
3 Type or paste these comments into the file following the function statement.
They display at the command line in response to the
help command. Follow
them by a blank line, which MATLAB requires to terminate the help text.
% SIMPLE_
GUI2 Select a data set from the pop-up menu, then
% click on
e of the plot-type push butt ons. Clicking the b utton
% plots th
e selected data in the axes.
(Leave a
blank line here)
4 Add an end statement at the end of the file. This end statement matches
the
function statement. Your file now looks like this.
functi
on simple_gui 2
% SIMPL
E_GUI2 Select a data set fr om the pop-up menu, then
%clic
k one of the plot-type push buttons. Clicking the button
%plot
s the selected data in the axes.
end
Note You need the end statement because the example is written using
nested functions. To learn more, see “Nested Functions”.
5 Save the file in your current folder o r at a location that is on your MAT LAB
path.
3-5