function [y1,...,yn]=foo(x1,...,xm) . . .where foo is the function name, the xi are the input arguments of the function, the yj are the output arguments from the function, and the three vertical dots represent the list of instructions performed by the function. An example of a function which calculates is as follows
function [x]=fact(k) k=int(k) if k<1 then k=1,end x=1; for j=1:k,x=x*j;end endfunctionIf this function is contained in a file called fact.sci the function must be ``loaded'' into Scilab by the exec or getf command and before it can be used:
--> exists('fact') ans = 0. --> exec('../macros/fact.sci',-1); --> exists('fact') ans = 1. --> x=fact(5) x = 120.In the above Scilab session, the command exists indicates that fact is not in the environment (by the 0 answer to exist). The function is loaded into the environment using exec and now exists indicates that the function is there (the answer). The example calculates .