Environmental Engineering Reference
In-Depth Information
with the function keyword. What follows is a list of output parameters, the equality
sign, the function name and a list of input parameters:
Also alike scripts functions are called by using the function name and formal
parameter sets for input and output.
either from the command window, from a script or from another function. The
filename must be identical with the function name, i.e. in the example: 'myfun.m'.
Formal parameters in the calling command and the function are identified on basis
of the parameter lists. They need not be identical! For example the call:
results in a continuation of the execution with the function commands, where the
parameter in1 obtains the value 5, and in2 gets the value of variable A . No output is
taken from the function in this case. By using
B and A obtain values calculated during execution of the function. Then the
function commands are executed, the execution returns to the calling statement and
proceeds with the following command.
Functions may contain subfunctions. Subfunctions are not visible outside the file
where they are defined. Normally functions return when the end of the function is
reached. The
statement can be used to force an early return. If there are functions with identical
names, the ones defined as subfunctions have priority. In general the programmer
may use the
command to find the location of function with highest priority. The
commands deliver the numbers for input resp. output parameters. This can be used
to deal with varying formal parameters, for example to allow the user to call the file
with a reduced number of parameters. This is feasible if for missing parameters
default values are specified.
Search WWH ::




Custom Search