1
functions Scilab Group Scilab Data type functions
3
functions - Scilab procedures and Scilab objects
6
Functions are Scilab procedures ("macro", "function" and "procedure" have
10
Usually, they are defined in files with an editor and loaded into Scilab
11
by getf or through a library (see lib or genlib). But They can also be
12
defined on-line (see deff or function o. A function is defined by two
15
- a "syntax definition" part as follows:
17
[y1,...,yn]=foo(x1,...,xm)
18
[y1,...,yn,varargout]=foo(x1,...,xm,varargin)
19
- a sequence of scilab instructions.
21
The "syntax definition" line gives the "full" calling syntax of this
22
function. The yi are output variables calculated as functions of input
23
variables xi and variables existing in Scilab when the function is
27
Usually function calling syntax is [y1,...,yn]=foo(x1,...,xm). Shorter
28
input or output argument list than definition ones may be used. In such
29
cases, only the first variables from the left are used of set. The argn
30
function may be used to get the actual number of calling arguments.
32
It is also possible to use "named argument" to specify input arguments:
33
suppose function fun1 defined as y1=fun1(x1,x2,x3) then it call be called
34
with a syntax like y=fun1(x1=33,x3=[1 2 3]) within fun1 x2 will be
35
undefined. It is possible to check for defined variables with the exists
38
When a function has no left hand side argument and is called only with
39
character string arguments, the callling syntax may be simplified
40
fun('a','toto','a string') can be replaced by fun a toto 'a string'
43
Functions are Scilab objects (with type numbers 13 or 11). They and can
44
be manipulated (built, saved, loaded, passed as arguments,..) as other
47
Collections of functions can be collected in libraries. Functions which
48
begin with % sign (e.g. %foo) are often used to overload (see
49
overloading) operations or functions for new data type.
52
//inline definition (see function)
53
function [x,y]=myfct(a,b)
60
//inline definition (see deff)
61
deff('[x,y]=myfct(a,b)',['x=a+b';
63
// definition in an ascii file (see exec)
64
exec SCI/macros/elem/asin.sci;
66
// definition in an ascii file (see getf)
67
getf SCI/macros/elem/asin.sci;
70
function, deff, getf, comp, lib, getd, genlib, exists, varargin,