1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
functions(1) Scilab Function functions(1)
NAME
functions - Scilab procedure and Scilab object
DESCRIPTION
Functions are Scilab procedures ("macro", "function" and "procedure" have
the save meaning). Usually, they are defined in files with an editor and
loaded into Scilab by getf or through a library (see lib).
They can also be defined on-line (see deff). A file which contains a func-
tion must begin as follows:
function [y1,...,yn]=foo(x1,...,xm)
The yi are output variables calculated as functions of input variables and
variables existing in Scilab when the function is executed.
A function can be compiled for faster execution. Collections of functions
can be collected in libraries. Functions which begin with % sign (e.g.
%foo) are often used to overload (see overloading) operations or function
for new data type: for example, z=%rmr(x,y) is equivalent to z=x*y when x
and z are rationals (i.e. x=tlist(['r','num','den','dt'],n,d,[]) with n and
d polynomials).
For example if the file myfct.sci contains:
function [x,y]=myfct(a,b)
x=a+b
y=a-b
you can load and use it in the following way:
getf('pathname/myfct.sci','c')
[a,b]=myfct(1,2)
SEE ALSO
deff, getf, comp, lib, function, overloading
|