Environmental Engineering Reference
In-Depth Information
Fig. 2.8 Graphical output of
'example.m' file
1
lambda = 1
lambda = 2
lambda = 3
0.8
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
1
A second graph appears. Proceed further:
A graph, showing stronger degradation with increasing lambda - value, appears.
It should look similar to Fig. 2.8
The example shows that it is convenient to call repeatedly appearing command
sequences in an M-file. The demonstration application is a mixture of commands on
the command window, and of editing a file. Alternatively the entire command
sequence can be started in an M-file. There is also an alternative way to start the
in the main menu of the editor. 6 The procedure is
current M-file: the button
exemplified in the next section. There is an alternative way to create an M-file
directly from the command history. One or several command in the command
history can be highlighted. By using the right mouse button one gets several
options. One option is to create a M-file directly from the selected commands.
There are two types of M-files: scripts and functions . Scripts are simply files
containing a sequence of commands. By typing the filename, the commands are
executed subsequently. Variables, which are not specified or initialized in the script
have to be available in the workspace, when the script is executed. Variables,
specified in a script, are available in the workspace after execution, if they are not
cleared explicitly.
Like scripts functions contain sequences of commands, and are stored with the
extension '.m'. Formally they differ from scripts as the first no-comment line starts
6 The button does not appear, when the editor is called outside of MATLAB
, for example by
®
double-click on a M-file from the operating system.
 
Search WWH ::




Custom Search