1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
4
<LANGUAGE>eng</LANGUAGE>
5
<TITLE>function</TITLE>
6
<TYPE>Scilab keyword</TYPE>
7
<DATE>April 1993</DATE>
8
<SHORT_DESCRIPTION name="function"> opens a function definition</SHORT_DESCRIPTION>
9
<SHORT_DESCRIPTION name="endfunction"> closes a function definition</SHORT_DESCRIPTION>
13
function <lhs_arguments>=<function_name><rhs_arguments>
22
<DESCRIPTION_ITEM label="<function_name>">
23
<SP>stands for the name of the function</SP>
25
<DESCRIPTION_ITEM label="<rhs_arguments>">
26
<SP>stands for the input argument list. It may be</SP>
28
<DESCRIPTION_ITEM label="-">
29
<SP>a comma separated sequence of variable names enclosed in parenthesis, like <VERB>(x1,...,xm)</VERB>. Last variable name can be the key word <VERB>varargin</VERB> (see varargin)</SP>
31
<DESCRIPTION_ITEM label="-">
32
<SP>the sequence <VERB>()</VERB> or nothing,if the function has no input argument.</SP>
34
<DESCRIPTION_ITEM label="<lhs_arguments>">
35
<SP>stands for the output argument list. It may be</SP>
37
<DESCRIPTION_ITEM label="-">
38
<SP>a comma separated sequence of variable names enclosed in brackets, like <VERB>[y1,...,yn]</VERB>. Last variable name can be the key word <VERB>varargout</VERB> (see varargout)</SP>
40
<DESCRIPTION_ITEM label="-">
41
<SP>the sequence <VERB>[]</VERB> ,if the function has no input argument. In this case the syntax may also be: <VERB>function <function_name><rhs_arguments></VERB></SP>
43
<DESCRIPTION_ITEM label="<statements>">
44
<SP>stands for a set of scilab instructions (statements) This syntax may be used to define function (see functions) inline or in a script file (see exec). For compatibility with old Scilab versions, functions defined in a script file containing only function definitions can be "loaded" into Scilab using the <VERB>getf</VERB> function.</SP>
48
The <VERB>function <lhs_arguments>=<function_name><rhs_arguments></VERB>
49
sequence cannot be split over several lines. This sequence can be
50
followed by statements in the same line if a comma of semi column is
53
function definitions can be nested</P>
57
//inline definition (see function)
58
function [x,y]=myfct(a,b)
65
//a one line function definition
66
function y=sq(x),y=x^2,endfunction
70
//nested functions definition
73
function y=sq(x), y=x^2,endfunction
80
// definition in an script file (see exec)
81
exec SCI/macros/elem/asin.sci;
88
<LINK>functions</LINK>