Next Contents

1  Programming

1.1   abort interrupt evaluation.




DESCRIPTION :

abort interrupts current evaluation and gives the prompt. Within a pause level abort return to level 0 prompt.


See Also : quit X, pause X, break X, abort X, quit X



1.2   addinter new functions interface incremental linking at run time




CALLING SEQUENCE :

addinter(files,spname,fcts)



PARAMETERS :




DESCRIPTION :

addinter performs incremental linking of a compiled C or Fortran new Scilab interface routine (see intersci documentation) and define corresponding scilab functions.

For machines using dlopen functionality one can unlink an interface with ulink
( use the command link('show') to get the number of the shared library ). And to reload a new version of an interface a call to ulink is necessary to get rid of the old version.

See link
for more precision on use.




See Also : link X, intersci X, newfun X, clearfun X



1.3   and - logical and




CALLING SEQUENCE :

b=and(A),  b=and(A,'*')
b=and(A,'r'), b=and(A,1)
b=and(A,'c'), b=and(A,2)
A&B



DESCRIPTION :

and(A) is the logical AND of elements of the boolean matrix A. and(A) returns %T ("true") iff all entries of A are %T.

y=and(A,'r')
(or, equivalently, y=and(A,1)) is the rowwise and. It returns in each entry of the row vector y the and of the rows of x (The and is performed on the row index : y(j)= and(A(i,j),i=1,m)).

y=and(A,'c')
(or, equivalently, y=and(A,2)) is the columnwise and. It returns in each entry of the column vector y the and of the columns of x (The and is performed on the column index: y(i)= and(A(i,j),j=1,n))).

A&B
gives the element-wise logical and of the booleans matrices A and B .A and B must be matrices with the same dimensions or one from them must be a single boolean.


See Also : not X, or X



1.4   ans answer




DESCRIPTION :

ans means "answer". Variable ans is created automatically when expressions are not assigned. ans contains the last unassigned evaluated expression.



1.5   apropos searches keywords in Scilab help




CALLING SEQUENCE :

apropos word
apropos 'string'



DESCRIPTION :

Looks for keywords in man/*/whatis files.


EXAMPLE :

apropos '+'
apropos ode 
apropos 'list of'



See Also : help X



1.6   argn number of arguments in a function call




CALLING SEQUENCE :

[lhs [,rhs] ]=argn(0)



DESCRIPTION :

This function is used inside a function definition. It gives the number of actual inputs rhs and output lhs parameters passed to the function when the function is called. It is usually used in function definitions to deal with optional arguments.


See Also : function X



1.7   backslash - left matrix division.




CALLING SEQUENCE :

x=A\\b



DESCRIPTION :

Backslash denotes left matrix division. x=A\b is a solution to A*x=b.

If A
is nonsingular x=A\b (uniquely defined) is equivalent to x=inv(A)*b.

If A
is singular, x is a least square solution. i.e. norm(A*x-b) is minimal. If A is full column rank, the least square solution, x=A\b, is uniquely defined (there is a unique x which minimizes norm(A*x-b)). If A is not full column rank, then the least square solution is not unique, and x=A\b, in general, is not the solution with minimum norm (the minimum norm solution is x=pinv(A)*b).

A.
\B is the matrix with (i,j) entry A(i,j)\B(i,j). If A (or B) is a scalar A.\B is equivalent to A*ones(B).\B (or A.\(B*ones(A))

A\.B is an operator with no predefined meaning. It may be used to define a new operator (see overloading) with the same precedence as * or /.


EXAMPLE :

A=rand(3,2);b=[1;1;1]; x=A\\b; y=pinv(A)*b;  x-y
A=rand(2,3);b=[1;1]; x=A\\b; y=pinv(A)*b; x-y, A*x-b, A*y-b
A=rand(3,1)*rand(1,2); b=[1;1;1]; x=A\\b; y=pinv(A)*b; A*x-b, A*y-b
A=rand(2,1)*rand(1,3); b=[1;1]; x=A\\b; y=pinv(A)*b; A*x-b, A*y-b 



See Also : slash X, inv X, pinv X, percent X, ieee X



1.8   binary binary file management




CALLING SEQUENCE :

[fd,err]=mopen('file-name' [, mode,  swap ])
[err]=mclose([fd])
[x]=mget([n,type,fd])       // default values n=1,type='l',fd=-1
[err]=mput(x [,type,fd])    // default values type='l',fd=-1
str=mgetstr([n,fd])         // default values n=1, fd=-1
[err]=mputstr(str [, fd]);  // default value  fd = -1 
[err]=meof([fd])            // default value  fd = -1 
mclearerr([fd])            // default value  fd = -1 
mseek(n [,fd, flag])            // default values fd = -1, flag = 'set'
mtell([fd])                    // default value  fd = -1



PARAMETERS :




DESCRIPTION :

A set of function to read and write binary files.

The type
parameter can be one of the following : The automatic swap of bytes can be cancelled by adding a third ( with value zero ) argument to the mopen function ( mopen(file,"wb",0)).

It is possible not to take care of the swap
status and explicitely specify for each data the way to store i.e as little or big endian. This is described now:

1


EXAMPLE  :

 
filen = 'test.bin'
mopen(filen,'wb');
mput(1996,'ull');mput(1996,'uls');mput(1996,'ubl');mput(1996,'ubs');
mput(1996,'l');mput(1996,'s');mput(98,'uc');mput(98,'c');
mput(1996,'d');mput(1996,'f');mput(1996,'ul');mput(1996,'us');
mclose();

mopen(filen,'rb')
if 1996<>mget(1,'ull') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'uls') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'ubl') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'ubs') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'l') ;write(%io(2),'BUG');end;
if 1996<>mget(1,'s') ;write(%io(2),'Bug');end;
if 98<>mget(1,'uc') ;write(%io(2),'Bug');end;
if 98<>mget(1,'c') ;write(%io(2),'Bug');end;
// with eventuel swap 
if 1996<>mget(1,'d') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'f') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'ul') ;write(%io(2),'Bug');end;
if 1996<>mget(1,'us') ;write(%io(2),'Bug');end;
mclose();

// an example with two files 

file1 = 'test1.bin';
file2 = 'test2.bin';
fd1=mopen(file1,'wb');
fd2=mopen(file2,'wb');
mput(1996,'ull',fd1);
mput(1996,'ull',fd2);
mclose(fd1);
mclose(fd2);

fd1=mopen(file1,'rb');
if 1996<>mget(1,'ull',fd1) ;write(%io(2),'Bug');end;
fd2=mopen(file2,'rb');
if 1996<>mget(1,'ull',fd2) ;write(%io(2),'Bug');end;
mclose(fd1);
mclose(fd2);

// and example with mseek 
file3='test3.bin'
fd1= mopen(file3,'wb');
for i=1:10, mput(i,'d'); end 
mseek(0);
mput(678,'d');
mseek(0,fd1,'end');
mput(932,'d');
mclose(fd1)
fd1= mopen(file3,'rb');
res=mget(11,'d')
res1=[1:11]; res1(1)=678;res1($)=932;
if res1<>res ;write(%io(2),'Bug');end;
mseek(0,fd1,'set');
// trying to read more than stored data 
res1=mget(100,'d',fd1);
if res1<>res ;write(%io(2),'Bug');end;
meof(fd1)
mclearerr(fd1)
mclose(fd1);

1.9   bool2s convert boolean matrix to a zero one matrix.




CALLING SEQUENCE :

bool2s(x)



PARAMETERS :




DESCRIPTION :

If x is a boolean matrix, bool2s(x) returns the matrix where "true" values are replaced by 1 and "false" value by 0.

If x
is a "standard" matrix, bool2s(x) returns the matrix where non-zero values are replaced by 1.




EXAMPLE :

bool2s([%t %t %f %t])
bool2s([2.3 0 10 -1])



See Also : boolean X, find X



1.10   boolean Scilab Objects, boolean variables and operators & | ~




DESCRIPTION :

A boolean variable is %T (for "true") or %F (for "false"). These variables can be used to define matrices of booleans, with the usual syntax. Boolean matrices can be manipulated as ordinary matrices for elements extraction/insertion and concatenation. Note that other usual operations (+, *, -, ^, etc) are undefined for booleans matrices, three special operators are defined for boolean matrices:


EXAMPLE :

[1,2]==[1,3]
[1,2]==1
a=1:5; a(a>2)



See Also : matrices X, or X, and X, not X



1.11   brackets - left and right brackets




CALLING SEQUENCE :

[a11,a12,...;a21,a22,...;...]
[s1,s2,...]=func(...)



PARAMETERS :




DESCRIPTION :

Left and right brackets are used to note vector and matrix concatenation. These symbols are also used to denote a multiple left-hand-side for a function call

Inside concatenation brackets, blank or comma characters mean "column concatenation", semicolumn and carriage-return mean "row concatenation".

Note : to avoid confusions it is safer to use commas instead of blank to separate columns.

Within multiple lhs brackets variable names must be separated by comma.


EXAMPLES :

[6.9,9.64; sqrt(-1) 0]
[1 +%i  2 -%i  3]
[]
['this is';'a string';'vector']
s=poly(0,'s');[1/s,2/s]
[tf2ss(1/s),tf2ss(2/s)]

[u,s]=schur(rand(3,3))



See Also : comma X, semicolumn X



1.12   break keyword to interrupt loops




DESCRIPTION :

Inside a for or while loop, the command break forces the end of the loop.


EXAMPLE :

k=0; while 1==1, k=k+1; if k > 100 then  break,end; end



See Also : while X, if X, for X, abort X, return X



1.13   call Fortran or C user routines call




CALLING SEQUENCE :

 
// long form 'out' is present 
[y1,...,yk]=call("ident",x1,px1,"tx1",...,xn,pxn,"txn",
                 "out",[ny1,my1],py1,"ty1",...,[nyl,myl],pyl,"tyl")
// short form : no 'out' parameter 
[y1,....,yk]=call("ident",x1,...,xn) 



PARAMETERS :




DESCRIPTION :

Interactive call of Fortran (or C) user program from Scilab. The routine must be previously linked with Scilab. This link may be done:

1 The meaning of each parameter is described now:

1 If an output variable coincides with an input variable (i.e. pyi=pxj ) one can pass only its position pyi . The size and type of yi are then the same as those of xi. If an output variable coincides with an input variable and one specify the dimensions of the output variable [myl,nyl] must follow the compatibility condition mxk*nxk >= myl*nyl.

In the case of short syntax , [y1,....,yk]=call("ident",x1,...,xn)
, the input parameters xi's and the name "ident" are sent to the interface routine Ex-fort. This interface routine is then very similar to an interface (see the source code in the directory SCIDIR/default/Ex-fort.f).

For example the following program:
        subroutine foof(c,a,b,n,m)
        integer n,m
        double precision a(*),b,c(*)
        do 10 i=1,m*n 
          c(i) = sin(a(i))+b
 10        continue
        end

link("foof.o","foof")
a=[1,2,3;4,5,6];b= %pi;
[m,n]=size(a);
// Inputs:
// a is in position 2 and double
// b                3     double
// n                4     integer
// m                5     integer
// Outputs:
// c is in position 1 and double with size [m,n]
c=call("foof",a,2,"d",b,3,"d",n,4,"i",m,5,"i","out",[m,n],1,"d");
returns the matrix c=2*a+b.

If your machine is a DEC Alpha, SUN Solaris or SGI you may have to change the previous command line link("foo.o","foo")
by one of the followings:
link('foof.o -lfor -lm -lc','foof').
link('foof.o -lftn -lm -lc','foof').
link('foof.o -L/opt/SUNWspro/SC3.0/lib/lib77 -lm -lc','foof').
The same example coded in C:
  void fooc(c,a,b,m,n) 
        double a[],*b,c[];
        int *m,*n;
      { double sin();
        int i;
        for ( i =0 ; i < (*m)*(*n) ; i++) 
               c[i] = sin(a[i]) + *b;        
        }

link("fooc.o","fooc","C") // note the third argument 
a=[1,2,3;4,5,6];b= %pi;
[m,n]=size(a);
c=call("fooc",a,2,"d",b,3,"d",m,4,"i",n,5,"i","out",[m,n],1,"d");



See Also : link X, c_link X, intersci X, addinter X



1.14   case keyword used in select




DESCRIPTION :

Keyword used in select ... case Use it in the following way:
select expr0,
 case expr1 then instructions1,
 case expr2 then instructions2,
 ...
 case exprn then instructionsn,
 [else instructions],
end



See Also : select X, while X, end X, for X



1.15   ceil rounding up




CALLING SEQUENCE :

[y]=ceil(x)



PARAMETERS :




DESCRIPTION :

ceil(x) returns an integer matrix made of rounded up elements


See Also : round X, floor X, int X



1.16   chdir changes Scilab current directory




CALLING SEQUENCE :

ierr=chdir('path-name')



PARAMETERS :




DESCRIPTION :

Change the current Scilab directory to 'path-name'


EXAMPLE :

chdir(TMPDIR);
if MSDOS then
  unix_w("dir");
else
  unix_w("ls");
end



See Also : getcwd X



1.17   clear kills variables




CALLING SEQUENCE :

clear a



DESCRIPTION :

This command kills variables which are not protected. It removes the named variables from the environment. By itself clear kills all the variables except the variables protected by predef. Thus the two commands predef(0) and clear remove all the variables.

Normally, protected variables are standard libraries and variables with the percent prefix.

Note the particular syntax clear a
and not clear(a). Note also that a=[] does not kill a but sets a to an empty matrix.


See Also : predef X, who X



1.18   clearfun remove primitive.




CALLING SEQUENCE :

clearfun('name')



DESCRIPTION :

clearfun('name') removes the primitive 'name' from the set of primitives (built-in functions) . This function allows to rename a primitive : a Scilab primitive can be replaced by a user-defined function. For experts...


See Also : newfun X, funptr X



1.19   code2str returns character string associated with Scilab integer codes.




CALLING SEQUENCE :

str=code2str(c)



PARAMETERS :




DESCRIPTION :

Returns character string associated with Scilab integer codes.str is such that c(i) is the Scilab integer code of part(str,i))


EXAMPLE :

code2str([-28 12 18 21 10 11])



See Also : str2code X



1.20   coeff coefficients of matrix polynomial




CALLING SEQUENCE  :

 
[C]=coeff(Mp [,v])



PARAMETERS :




DESCRIPTION :

C=coeff(Mp) returns in a big matrix C the coefficients of the polynomial matrix Mp . C is partitioned as C=[C0,C1,...,Ck] where the Ci are arranged in increasing order k = maxi(degree(Mp))

C=coeff(Mp,v) returns the matrix of coefficients with degree in v . (v is a row or column vector).


See Also : poly X, degree X



1.21   colon - colon operator




DESCRIPTION :

The colon notation can also be used to pick out selected rows, columns and elements of vectors and matrices.


See Also : matrix X



1.22   comma - column, instruction, argument separator




DESCRIPTION :

Commas are used to separate parameters in functions or to separate entries of row vectors.

Blanks can also be used to separate entries in a row vector but use preferably commas.

Also used to separate Scilab instructions. (Use ;
to have the result not displayed on the screen).


EXAMPLES :

a=[1,2,3;4,5,6];
a=1,b=1;c=2

1.23   comments comments




DESCRIPTION :

Command lines which begin by // are not interpreted by Scilab.

Comments must not begin with //end
!



1.24   comp scilab function compilation




CALLING SEQUENCE :

comp(function [,opt])



PARAMETERS :




DESCRIPTION :

comp(function) compiles the function function. Compiled and interpreted functions are equivalent but usually compiled functions are much faster. The functions provided in the standard libraries are compiled.

The command:
getf('filename') loads the functions in file 'filename' and compiles them. So comp has to be used in very particular cases.

The opt==1 option is specific to code analysis purpose (see macr2lst)


REMARKS :

commands who, help, what cannot be compiled.


See Also : deff X, getf X, whereis X, macr2lst X, lib X



1.25   deff on-line definition of function




CALLING SEQUENCE  :

deff('[s1,s2,...]=newfunction(e1,e2,....)',text [,opt])



PARAMETERS :




DESCRIPTION :

On-line definition of function (user defined function): the name of the created function is newfunction. text is a sequence of instructions usually set as a vector of character strings.

This command can be used inside a function and the new function can be an input or output of any other function.

Usually, functions are defined in a file and loaded into Scilab by getf


Some time, in particular when you want to use define strings within deff text is rather difficult to write. A more tractable way may be to define your function in a file as usual, to load it into Scilab by getf (without 'c' option) and use sci2exp to get corresponding deff instructions.


EXAMPLES :

deff('[x]=myplus(y,z)','x=y+z')
//
deff('[x]=mymacro(y,z)',['a=3*y+1'; 'x=a*z+y'])



See Also : getf X, comp X, exec X, function X



1.26   degree degree of polynomial matrix




CALLING SEQUENCE :

[D]=degree(M) 



PARAMETERS :




DESCRIPTION :

returns the matrix of highest degrees of M.


See Also : poly X, coeff X, clean X



1.27   delbpt delete breakpoint




CALLING SEQUENCE :

delbpt('macroname' [,linenumb]) 



DESCRIPTION :

deletes the breakpoint at line linenumb in the function macroname. If linenumb is omitted all the breakpoints in the function are deleted.


EXAMPLE :

setbpt('foo',1),setbpt('foo',10),delbpt('foo',10),dispbpt()



See Also : setbpt X, dispbpt X, pause X, resume X



1.28   diary diary of session




CALLING SEQUENCE :

diary('file-name')



DESCRIPTION :

diary creates a file which contains a copy of the current Scilab session. diary(0) interrupts the diary.


See Also : exec X, unix X



1.29   disp displays variables




CALLING SEQUENCE :

disp(x1,[x2,...xn]) 



DESCRIPTION :

displays xi with the current format. xi's are arbitrary objects (matrices of constants, strings, functions, lists, ...)

Display of objects defined by tlist
may be overloaded by the definition of a function. This function must have no output argument a single input argument ant it's name is formed as follow %<tlist_type>_p where %<tlist_type> stands for the first entry of the tlist type component.


See Also : write X, read X, print X, string X, tlist X


EXAMPLES :

disp([1 2],3)
deff('[]=%t_p(l)','disp(l(3),l(2))')
disp(tlist('t',1,2))

1.30   dispbpt display breakpoints




CALLING SEQUENCE :

dispbpt()



DESCRIPTION :

dispbpt() displays all active breakpoints actually inserted in functions.


See Also : setbpt X, delbpt X, pause X, resume X



1.31   dot - symbol




CALLING SEQUENCE  :

 
123.33
a.*b
[123,..
 456]
.SH DESCRIPTION
.TP 6
. 
Dot is used to mark decimal point for numbers : 3.25 and 0.001
.TP
.<op>
used in cunjunction with other operator symbols (* / \\ ^ ') to form
other operators.  Element-by-element multiplicative operations are
obtained using .* , .^ , ./ , .\\ or .'.  For example, C = A ./ B is
the matrix with elements c(i,j) = a(i,j)/b(i,j). Kronecker product is
noted .*. .

Note that when dot follows a number it is alway prt of the number so 2.*x is evaluated as 2.0*x and 2 .*x is evaluated as (2).*x
.TP
.. 
Continuation.  Two or more decimal points at the end of
a line causes the following line to be a continuation.
.SH EXAMPLE
.nf
1.345
x=[1 2 3];x.^2 .*x // a space is required between 2 and dot
[123,..
 456]



See Also : star X, hat X, slash X, backslash X



1.32   else keyword in if-then-else




DESCRIPTION :

Used with if.


See Also : if X



1.33   elseif keyword in if-then-else




DESCRIPTION :

See if,then,else .



1.34   empty - empty matrix




DESCRIPTION :

[] denotes the empty matrix. It is uniquely defined and has 0 row and 0 column, i.e. size([]) =[0,0] . The following convenient conventions are made:

[] * A = A * [] = []


[] + A = A + [] = A

[ [], A] = [A, []] = A inv([]) =[]

det([])=cond([])=rcond([])=1, rank([])=0

Matrix functions return [] or an error message when there is no obvious answer. Empty linear systems ( syslin lists) may have several rows or columns.


EXAMPLE :

s=poly(0,'s'); A = [s, s+1]; 
A+[], A*[]
A=rand(2,2); AA=A([],1), size(AA)
svd([])
w=ssrand(2,2,2); wr=[]*w; size(wr), w1=ss2tf(wr), size(w1)



See Also : matrices X, poly X, string X, boolean X, rational X, syslin X



1.35   end end keyword




DESCRIPTION :

Used at end of loops or conditionals. for, while, if, select must be terminated by end .




See Also : for X, while X, if X, select X



1.36   equal - affectation, comparison equal sign




DESCRIPTION :

Equal sign is used to denote a value affectation to a variable.

== denote equality comparison between two expressions and returns a boolean matrix.


EXAMPLES :

a=sin(3.2)
[u,s]=schur(rand(3,3))
[1:10]==4
1~=2



See Also : less X, boolean X



1.37   errcatch error trapping




CALLING SEQUENCE :

errcatch(n [,'action'] [,'option']) 



PARAMETERS :




DESCRIPTION :

errcatch gives an "action" (error-handler) to be performed when an error of type n occurs. n has the followin meaning:

if n
>0, n is the error number to trap

if n
<0 all errors are to be trapped

action
is one of the following character strings:

1

2 option is the character string 'nomessage' for killing error message.


See Also : errclear X, iserror X



1.38   errclear error clearing




CALLING SEQUENCE :

errclear([n])



DESCRIPTION :

clears the action (error-handler) connected to error of type n.

If n
is positive, it is the number of the cleared error ; otherwise all errors are cleared (default case)


See Also : errcatch X



1.39   error error messages




CALLING SEQUENCE :

error('string' [,n])
error(m)



DESCRIPTION :

prints the character string 'string' in an error message and stops the current instruction.

If n
is given, it is associated to the number of the error. n should be larger than 10000 (default value).

error(m)
prints the message associated with the error number m.


See Also : warning X



1.40   evstr evaluation of expressions




CALLING SEQUENCE :

H=evstr(Z)
[H,ierr]=evstr(Z)



PARAMETERS :




DESCRIPTION :

returns the evaluation of the matrix of character strings. Each element of the M matrix must be a character string defining a scilab expression.

If evaluation of M expression leads to an error H=evstr(M)
produces an error which is handled as usual. [H,ierr]=evstr(M) produces an error message and return the error number in ierr.

If Z
is a list, Subexp is a character strings vector which defines sub_expressions evaluated before evaluation of M. These sub_expressions must be referred as %(k) in M (k is the sub-expression index in Subexp).

evstr('a=1') is not valid (use execstr
).




EXAMPLES :

a=1; b=2; Z=['a','b'] ; evstr(Z) 

a=1; b=2; Z =list(['%(1)','%(1)-%(2)'],['a+1','b+1']);
evstr(Z)



See Also : execstr X



1.41   exec script file execution




CALLING SEQUENCE :

exec('file-name' [,mode])



DESCRIPTION :

executes the content of the file 'file-name' with an optional execution mode mode .

The different cases for mode
are :


REMARK :

Last line of startup file must be terminated by a newline to be taken into account.


See Also : getf X, comp X, mode X



1.42   exists checks variable existence




CALLING SEQUENCE :

exists(name [,where])



PARAMETERS :




DESCRIPTION :

exists(name) returns 1 if the variable named name exists and 0 otherwise.

Caveats: a function which uses exists
may return a result which depends on the environment!

exists(name,'local')
returns 1 if the variable named name exists in the local environment of the current function and 0 otherwise.




EXAMPLE :

deff('foo(x)',..
['disp([exists(''a12''),exists(''a12'',''local'')])'
 'disp([exists(''x''),exists(''x'',''local'')])'])
foo(1)
a12=[];foo(1)



See Also : isdef X, whereis X, type X, typeof X, macrovar X



1.43   exit Ends the current Scilab session




DESCRIPTION :

Ends the current Scilab session.


See Also : quit X, abort X, break X, return X, resume X



1.44   external Scilab Object, external function or routine




DESCRIPTION :

External function or routine for use with specific commands.

An "external" is a function or routine which is used as an argument of some high-level primitives (such as ode
, optim, schur...).

The calling sequence of the external (function or routine) is imposed by the high-level primitive which sets the arguments of the external.

For example the external function costfunc
is an argument of the optim primitive. Its calling sequence must be: [f,g,ind]=costfunc(x,ind) and optim (the high-level optimization primitive) is invoked as follows:
optim(costfunc,...)
Here costfunc (the cost function to be minimized by the primitive optim) evaluates f=f(x) and g= gradient of f at x (ind is an integer which is not useful here).

If other values are needed by the external function these variables can be defined in the environment. Also, they can be put in a list. For example,the external function
[f,g,ind]=costfunc(x,ind,a,b,c) 
is valid for optim if the external is list(costfunc,a,b,c) and the call to optim is then:
optim(list(costfunc,a1,b1,c1),....
An external can also be a Fortran routine : this is convenient to speed up the computations.

The name of the routine is given to the high-level primitive as a character string. The calling sequence of the routine is also imposed. Examples are given in the routines/default
directory (see the README file).

External Fortran routines can also be dynamically linked (see link
)


See Also : ode X, optim X, impl X, dassl X, intg X, schur X, gschur X



1.45   extraction matrix and list entry extraction




CALLING SEQUENCE :

x(i,j)
x(i)
[...]=l(i)
[...]=l(k1)...(kn)(i) or [...]=l(list(k1,...,kn,i))
l(k1)...(kn)(i,j)   or l(list(k1,...,kn,list(i,j))



PARAMETERS :




DESCRIPTION :




REMARKS :

For soft coded matrix types such as rational functions and state space linear systems, x(i) syntax may not be used for vector element extraction due to confusion with list element extraction. x(1,j) or x(i,1) syntax must be used.


EXAMPLE :

// MATRIX CASE
a=[1 2 3;4 5 6]
a(1,2)
a([1 1],2)
a(:,1)
a(:,3:-1:1)
a(1)
a(6)
a(:)
a([%t %f %f %t])
a([%t %f],[2 3])
a(1:2,$-1)
a($:-1:1,2)
a($)
//
x='test'
x([1 1;1 1;1 1])
//
b=[1/%s,(%s+1)/(%s-1)]
b(1,1)
b(1,$)
b(2) // the numerator
// LIST OR TLIST CASE
l=list(1,'qwerw',%s)
l(1)
[a,b]=l([3 2])
l($)
x=tlist(l(2:3)) //form a tlist with the last 2 components of l
//
dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
dts(2)('a')
dts(2)('b')(1,2)
[a,b]=dts(2)(['a','b'])




See Also : find X, horner X, parents X



1.46   eye identity matrix




CALLING SEQUENCE :

X=eye(m,n)
X=eye(A)
X=eye()



PARAMETERS :




DESCRIPTION :

according to its arguments defines an mxn matrix with 1 along the main diagonal or an identity matrix of the same dimension as A .

Caution: eye(10)
is interpreted as eye(A) with A=10 i.e. 1. (It is NOT a ten by ten identity matrix!).

If A
is a linear system represented by a syslin list, eye(A) returns an eye matrix of appropriate dimension: (number of outputs x number of inputs).

eye()
produces a identity matrix with undefined dimensions. Dimensions will be defined when this identity matrix is added to a mtrix with fixed dimensions.


EXAMPLES :

eye(2,3)
A=rand(2,3);eye(A)
s=poly(0,'s');A=[s,1;s,s+1];eye(A)
A=[1/s,1;s,2];eye(A);
A=ssrand(2,2,3);eye(A)
[1 2;3 4]+2*eye()



See Also : ones X, zeros X



1.47   feval multiple evaluation




CALLING SEQUENCE :

[z]=feval(x,y,f)
[z]=feval(x,f)



PARAMETERS :




DESCRIPTION :

Multiple evaluation of a function for one or two arguments of vector type : f is an external (function or routine) depending on one or two arguments which are supposed to be real. The result returned by f can be real or complex. In case of a Fortran call, the function 'f' must be defined in the subroutine ffeval.f (in directory SCIDIR/routines/default)


EXAMPLE :

deff('[z]=f(x,y)','z=x^2+y^2');
feval(1:10,1:5,f)
deff('[z]=f(x,y)','z=x+%i*y');
feval(1:10,1:5,f)
feval(1:10,1:5,'parab')   //See ffeval.f file
feval(1:10,'parab')
// For dynamic link (see example ftest in ffeval.f)
// you can use the link command (the parameters depend on the machine):
// unix('make ftest.o');link('ftest.o','ftest); feval(1:10,1:5,'ftest') 



See Also : evstr X, horner X, execstr X, external X, link X



1.48   file file management




CALLING SEQUENCE :

[unit [,err]]=file('open', file-name [,status] [,access [,recl]] [,format])
file(action,unit)



PARAMETERS :




DESCRIPTION :

selects a logical unit unit and manages the file file-name.

[unit [,err]]=file('open', file-name [,status] [,access [,recl]] [,format])
allows to open a file with specified properties and to get the associated unit number unit. This unit number may be used for further actions on this file or as file descriptor in read, write, readb, writb,save, load function calls.

file(action,unit)
allows to close the file , or move the current file pointer .


EXAMPLE :

u=file('open',TMPDIR+'/foo','unknown')
for k=1:4
  a=rand(1,4)
  write(u,a)
end
file('rewind',u)
x=read(u,2,4)
file('close',u)



See Also : save X, load X, write X, read X, writb X, readb X, xgetfile X



1.49   find find indices of boolean vector or matrix true elements




CALLING SEQUENCE :

[ii]=find(x)
[ir,ic]=find(x)



PARAMETERS :




DESCRIPTION :

If x is a boolean matrix,

ii=find(x) returns the vector of indices i for which x(i) is "true". If no true element found find returns an empty matrix.

[ir,ic]=find(x) returns two vectors of indices ir (for rows) and ic (for columns) such that x(il(n),ic(n)) is "true". If no true element found find returns empty matrices in ir and ic .

if x is standard matrix find(x) is interpreted as find(x
<>0)

find([]) returns []


EXAMPLE :

A=rand(1,20);
w=find(A<0.5);
A(w)
w=find(A>100);



See Also : boolean X, extraction X, insertion X



1.50   fix rounding towards zero




CALLING SEQUENCE :

[y]=fix(x)



PARAMETERS :




DESCRIPTION :

fix(x) returns an integer matrix made of nearest rounded integers toward zero,i.e, y=sign(x).*floor(abs(x)). Same as int.


See Also : round X, floor X, ceil X



1.51   floor rounding down




CALLING SEQUENCE :

[y]=floor(x)



PARAMETERS :




DESCRIPTION :

floor(x) returns an integer matrix made of nearest rounded down integers.


See Also : round X, fix X, ceil X



1.52   for language keyword for loops




DESCRIPTION :

Used to define loops. Its syntax is:

for variable=expression ,instruction, ,instruction,end

for variable=expression do instruction, ,instruction,end

If expression
is a matrix or a row vector, variable takes as values the values of each column of the matrix.

Useful example : for variable=n1:step:n2, ...,end


If expression is a list variable takes as values the successive entries of the list.


EXAMPLE :

n=5;
for i = 1:n, for j = 1:n, a(i,j) = 1/(i+j-1);end;end
for j = 2:n-1, a(j,j) = j; end; a
for  e=eye(3,3),e,end  
for v=a, write(6,v),end        
for j=1:n,v=a(:,j), write(6,v),end 
for l=list(1,2,'example'); l,end 

1.53   format printing format




CALLING SEQUENCE :

format([type],[long])



PARAMETERS :




DESCRIPTION :

Sets the current printing format with the parameter type ; it is one of the following : long defines the max number of digits (default 10). format() returns a vector for the current format: first component is the type of format (0 if v ; 1 if e ); second component is the number of digits.


See Also : write X



1.54   fort Fortran or C user routines call




CALLING SEQUENCE :

 
// long form 'out' is present 
[y1,...,yk]=fort("ident",x1,px1,"tx1",...,xn,pxn,"txn",
                 "out",[ny1,my1],py1,"ty1",...,[nyl,myl],pyl,"tyl")
// short form : no 'out' parameter 
[y1,....,yk]=fort("ident",x1,...,xn) 



PARAMETERS :




DESCRIPTION :

Interactive call of Fortran (or C) user program from Scilab. The routine must be previously linked with Scilab. This link may be done:

1 The meaning of each parameter is described now:

1 If an output variable coincides with an input variable (i.e. pyi=pxj ) one can pass only its position pyi . The size and type of yi are then the same as those of xi. If an output variable coincides with an input variable and one specify the dimensions of the output variable [myl,nyl] must follow the compatibility condition mxk*nxk >= myl*nyl.

In the case of short syntax , [y1,....,yk]=fort("ident",x1,...,xn)
, the input parameters xi's and the name "ident" are sent to the interface routine Ex-fort. This interface routine is then very similar to an interface (see the source code in the directory SCIDIR/default/Ex-fort.f).

For example the following program:
        subroutine foof(c,a,b,n,m)
        integer n,m
        double precision a(*),b,c(*)
        do 10 i=1,m*n 
          c(i) = sin(a(i))+b
 10        continue
        end

link("foof.o","foof")
a=[1,2,3;4,5,6];b= %pi;
[m,n]=size(a);
// Inputs:
// a is in position 2 and double
// b                3     double
// n                4     integer
// m                5     integer
// Outputs:
// c is in position 1 and double with size [m,n]
c=fort("foof",a,2,"d",b,3,"d",n,4,"i",m,5,"i","out",[m,n],1,"d");
returns the matrix c=2*a+b.

If your machine is a DEC Alpha, SUN Solaris or SGI you may have to change the previous command line link("foo.o","foo")
by one of the followings:
link('foof.o -lfor -lm -lc','foof').
link('foof.o -lftn -lm -lc','foof').
link('foof.o -L/opt/SUNWspro/SC3.0/lib/lib77 -lm -lc','foof').
The same example coded in C:
  void fooc(c,a,b,m,n) 
        double a[],*b,c[];
        int *m,*n;
      { double sin();
        int i;
        for ( i =0 ; i < (*m)*(*n) ; i++) 
               c[i] = sin(a[i]) + *b;        
        }

link("fooc.o","fooc","C") // note the third argument 
a=[1,2,3;4,5,6];b= %pi;
[m,n]=size(a);
c=fort("fooc",a,2,"d",b,3,"d",m,4,"i",n,5,"i","out",[m,n],1,"d");



See Also : link X, c_link X, intersci X, addinter X



1.55   fprintf Emulator of C language fprintf function




CALLING SEQUENCE :

fprintf(file,format,value_1,..,value_n)



PARAMETERS :




DESCRIPTION :

The fprintf function converts, formats, and writes its value parameters, under control of the format parameter, to the file specified by its file parameter.

The format
parameter is a character string that contains two types of objects: If any values remain after the entire format has been processed, they are ignored.




EXAMPLES :

u=file('open','results','unknown') //open the result file
t=0:0.1:2*%pi;
for tk=t
 fprintf(u,'time = %6.3f value = %6.3f',tk,sin(tk)) // write a line
end
file('close',u) //close the result file



See Also : string X, print X, write X, format X, disp X, file X, printf X, sprintf X



1.56   fscanf Converts formatted input read on a file




CALLING SEQUENCE :

 [v_1,...v_n]=fscanf (file,format)



PARAMETERS :




DESCRIPTION :

The fscanf functions read character data on the file specified by the file argument , interpret it according to a format, and returns the converted results.

The format parameter contains conversion specifications used to interpret the input.

The format parameter can contain white-space characters (blanks, tabs, newline, or formfeed) that, except in the following two cases, read the input up to the next nonwhite-space character. Unless there is a match in the control string, trailing white space (including a newline character) is not read.



See Also : printf X, read X, scanf X, sscanf X



1.57   funcprot switch scilab functions protection mode




CALLING SEQUENCE :

prot=funcprot()
funcprot(prot)



PARAMETERS :




DESCRIPTION :

Scilab functions are variable, funcprot allows the user to specify what scilab do when such variables are redefined.

1


EXAMPLE :

funcprot(1) deff('[x]=foo(a)','x=a') deff('[x]=foo(a)','x=a+1') foo=33 funcprot(0) deff('[x]=foo(a)','x=a') deff('[x]=foo(a)','x=a+1') foo=33



1.58   function 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 function 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 X, getf X, comp X, lib X, function X, overloading X



1.59   funptr coding of primitives ( wizard stuff )




DESCRIPTION :

Utility function (for experts only) funptr('name') returns 100*fun + fin where (fun,fin) is the internal coding of the primitive 'name' . fun is the interface number and fin the routine number


See Also : clearfun X, newfun X



1.60   getcwd get Scilab current directory




CALLING SEQUENCE :

path=getcwd()
pwd



PARAMETERS :




DESCRIPTION :

return in path the Scilab current directory.


EXAMPLE :

p=getcwd();
pwd



See Also : chdir X, unix X



1.61   getd getting function defined in a directory .sci files




CALLING SEQUENCE :

getd(path)



PARAMETERS :




DESCRIPTION :

loads all function defined in the directory .sci files


EXAMPLE :

getd('SCI/macros/auto')



See Also : getf X, lib X



1.62   getenv get the value of an environment variable




CALLING SEQUENCE :

env=getenv(str [, rep] )



PARAMETERS :




DESCRIPTION :

Return the value of an environment variable if it exists.


EXAMPLE :

        getenv('SCI')
        getenv('FOO','foo') 

1.63   getf loading function




CALLING SEQUENCE :

getf(file-name [,opt])



PARAMETERS :




DESCRIPTION :

loads one or several functions defined in the file 'file-name'. The string opt='c' means that the functions are to be compiled (pre-interpreted) when loaded. (see comp). The first line of the file must be as follows:
function [s1,s2,..,slhs]=macr(e1,e2,...,erhs)  
ei are input variables and si are output variables.


REMARK :

Last line of file must be terminated by a newline to be taken into account.


EXAMPLE :

        getf('SCI/macros/xdess/plot.sci')



See Also : comp X, exec X, edit X



1.64   getpid get Scilab process identificator




CALLING SEQUENCE :

id=getpid()



DESCRIPTION :

Return an the scilab process identificator integer


EXAMPLE :

d='SD_'+string(getpid())+'_'

1.65   hat - exponentiation




CALLING SEQUENCE :

A^b



DESCRIPTION :

Exponentiation of matrices or vectors by a constant vector.

If A
is a vector or a rectangular matrix the exponentiation is done element-wise, with the usual meaning.

For square A
matrices the exponentiation is done in the matrix sense.

For boolean, polynomial and rational matrices, the exponent must be an integer

Remark that 123.^b
is interpreted as (123).^b. In such cases dot is part of the operator, not of the number.




EXAMPLES :

2^4
[1 2;2 4]^(1+%i)
s=poly(0,"s");
[1 2 s]^4
[s 1;1  s]^(-1)



See Also : exp X, inv X



1.66   help on-line help command




CALLING SEQUENCE :

        help word



DESCRIPTION :

To each documented word corresponds a word.cat ascii file. these files are organised within directories (chapters). Each chapter must contain *.cat files and a whatis file with one line for each documented word in the chapter. Each line must have the following format :

word - quick description
List of chapter directories is given in a file (whose path is given in the $MANCHAPTERS environment variable) with the following format for each chapter:

chapter_path    chapter_title
MANCHAPTERS default value is SCI/man/Chapters. If you want to add new help chapters you have to do a copy of the SCIDIR/man/Chapters file where you want, to add descriptions lines for each new chapter and to define the new value of MANCHAPTERS environment variable.

See also Scilab's manual


See Also : apropos X



1.67   host shell (sh) command execution




CALLING SEQUENCE :

stat=host(command-name)



PARAMETERS :




DESCRIPTION :

Sends a string command-name to Unix for execution by the sh shell. Standard output and standard errors of the shell command are written in the calling shell. stat gives -1 if host can't be called (Not enough system memory available) or the sh return code.


EXAMPLE :

host("ls $SCI/demos");
host("emacs $SCI/demos/wheel2/Makefile");
deff('wd=pwd()','if MSDOS then host(''cd>''+TMPDIR+''\path'');..
                 else host(''pwd>''+TMPDIR+''/path'');end..
      wd=read(TMPDIR+''/path'',1,1,''(a)'')')
wd=pwd()



See Also : edit X, manedit X, unix_g X, unix_s X, unix_w X, unix_x X



1.68   hypermat initialize an N dimensional matrices




CALLING SEQUENCE :

M=hypermat(dims [,v])



PARAMETERS :




DESCRIPTION :

Initialize an hypermatrix whose dimensions are given in the vector dims and entries are given in optional argument v M data structure contains the vector of matrix dimensions M('dims') and the vector of entries M('entries') such as the leftmost subcripts vary first [M(1,1,..);..;M(n1,1,..);...;M(1,n2,..);..;M(n1,n2,..);...]


EXAMPLES :

M=hypermat([2 3 2 2],1:24)

1.69   hypermatrices Scilab object, N dimensional matrices in Scilab




DESCRIPTION :

Hypermatrix type allows to manipulate multidimensional arrays

They can be defined by extension of 2D matrices as follows a=[1 2;3 4];a(:,:,2)=rand(2,2)

or directly using hypermat
function

Entries can be real or complex numbers, polynomials, rationals, strings, booleans.

Hypermatrices are mlists
: mlist(['hm','dims','entries'],sz,v) where sz is the row vector of dimensions and v the column vector of entries (first dimension are stored first)




EXAMPLES :

a(1,1,1,1:2)=[1 2]
a=[1 2;3 4];a(:,:,2)=rand(2,2)
a(1,1,:)
[a a]



See Also : hypermat X



1.70   ieee set floating point exception mode




CALLING SEQUENCE :

mod=ieee()
ieee(mod)



PARAMETERS :




DESCRIPTION :

ieee() returns the current floating point exception mode. The initial mode value is 0.




REMARKS :

Floating point exeception arizing inside some library algorithms are not yet handled by ieee modes.


EXAMPLE :

ieee(1);1/0
ieee(2);1/0,log(0)



See Also : errcatch X



1.71   if else - conditional execution




SYNTAX :

if expr1 then statements
elseif expri then statements
  ....
else  statements
end



DESCRIPTION :

The if statement evaluates a logical expression and executes a group of statements when the expression is true.

The expri
are expressions with numeric or boolean values. If expri are matrix valued the condition is true only if all matrix entries are true.

The optional elseif
and else provide for the execution of alternate groups of statements. An end keyword, which matches the if, terminates the last group of statements. The line structure given above is not significant, the only constraint is that each then keyword must be on the same line line as its corresponding if or elseif keyword.




EXAMPLE :

   i=2
   for j = 1:3, 
      if i == j then
        a(i,j) = 2; 
      elseif abs(i-j) == 1 then 
        a(i,j) = -1; 
      else a(i,j) = 0;
      end,
   end



See Also : while X, select X, boolean X, end X, then X, else X



1.72   imag imaginary part




CALLING SEQUENCE :

[y]=imag(x)



PARAMETERS :




DESCRIPTION :

imag(x) is the imaginary part of x. (See %i to enter complex numbers).


See Also : real X



1.73   insertion matrix and list insertion or modification




CALLING SEQUENCE :

x(i,j)=a
x(i)=a
l(i)=a
l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
l(k1)...(kn)(i,j)=a   or l(list(k1,...,kn,list(i,j))=a



PARAMETERS :




DESCRIPTION :

if a is a scalar x(i,j)=a returns a new x matrix such as x(int(i(l)),int(j(k)))=a for l from 1 to size(i,'*') and k from 1 to size(j,'*'), other initial entries of x are unchanged.

If i
or j maximum value exceed corresponding x matrix dimension x is previously extended to the required dimensions with zeros entries for standard matrices, 0 length character string for string matrices and false values for boolean matrices.

x(i)=a with a a scalar returns a new x matrix such as x(int(i(l)))=a for l from 1 to size(i,'*') , other initial entries of x are unchanged.

If i
maximum value exceed size(x,1), x is previously extended to the required dimension with zeros entries for standard matrices, 0 length character string for string matrices and false values for boolean matrices.

3


REMARKS :

For soft coded matrix types such as rational functions and state space linear systems, x(i) syntax may not be used for vector entry insertion due to confusion with list entry insertion. x(1,j) or x(i,1) syntax must be used.




EXAMPLE :

// MATRIX CASE
a=[1 2 3;4 5 6]
a(1,2)=10
a([1 1],2)=[-1;-2]
a(:,1)=[8;5]
a(1,3:-1:1)=[77 44 99]
a(1)=%s
a(6)=%s+1
a(:)=1:6
a([%t %f],1)=33
a(1:2,$-1)=[2;4]
a($:-1:1,1)=[8;7]
a($)=123
//
x='test'
x([4 5])=['4','5']
//
b=[1/%s,(%s+1)/(%s-1)]
b(1,1)=0
b(1,$)=b(1,$)+1
b(2)=[1 2] // the numerator
// LIST OR TLIST CASE
l=list(1,'qwerw',%s)
l(1)='Changed'
l(0)='Added'
l(6)=['one more';'added']
//
//
dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
dts(2)('a')=33
dts(2)('b')(1,2)=-100



See Also : find X, horner X, parents X, extraction X



1.74   int integer part




CALLING SEQUENCE :

[y]=int(X)



PARAMETERS :




DESCRIPTION :

int(X) returns the integer part of the real matrix X. Same as fix.


See Also : round X, floor X, ceil X



1.75   intersci scilab tool to interface C of Fortran functions with scilab




DESCRIPTION :

All scilab primitive functions are defined in a set of interface routines. For each function the interfacing code checks first number of rhs and lhs arguments. Then it get pointers on input arguments in the Scilab data base and checks their types. After that it calls procedure associated with Scilab functions, checks returned errors flags and set the results in the data base.

intersci
is a program which permits to interface automatically FORTRAN subroutines or C functions to Scilab

With intersci
, a user can group all his FORTRAN or C code into a same set, called an interface, and use them in Scilab as Scilab functions. The interfacing is made by creating a FORTRAN subroutine which has to be linked to Scilab together with the user code. This complex FORTRAN subroutine is automatically generated by intersci from a description file of the interface.

Refer to intersci documentation for more details.


See Also : fort X, external X, addinter X



1.76   iserror error test




CALLING SEQUENCE :

iserror([n])



DESCRIPTION :

tests if error number n has occurred (after a call to errcatch). iserror returns 1 if the error occurred a nd 0 otherwise

n
>0 is the error number ; all errors are tested with n<0.


See Also : error X, errcatch X



1.77   keyboard keyboard commands




DESCRIPTION :

Let C- stands for the control key. The following keyboard commands are available:


See Also : pause X, read X, input X



1.78   left - left bracket




CALLING SEQUENCE :

[a11,a12,...;a21,a22,...;...]
[s1,s2,...]=func(...)



PARAMETERS :




DESCRIPTION :

Left and right brackets are used for vector and matrix concatenation. These symbols are also used to denote a multiple left-hand-side for a function call

Inside concatenation brackets blank or comma characters mean "column concatenation", semicolumn and carriage-return mean "row concatenation".

Note : to avoid confusions it is safer to use comma instead of blank to separate columns.

Within multiple lhs brackets variable names must be separated by comma.


EXAMPLES :

[6.9,9.64; sqrt(-1) 0]
[1 +%i  2 -%i  3]
[]
['this is';'a string';'vector']

[u,s]=schur(rand(3,3))

1.79   length length of object




CALLING SEQUENCE :

n=length(M) 



PARAMETERS :




DESCRIPTION :

For usual or polynomial matrix n is the integer equal to number of rows times number of columns of M. (Also valid for M a boolean matrix)

For matrices made of character strings (and in particular for a character string) length
returns in n the length of entries of the matrix of character strings M.

The length of a list is the number of elements in the list (also given by size
).

length('123')
is 3. length([1,2;3,4]) is 4.


See Also : size X



1.80   less - lower than comparison




DESCRIPTION :

logical comparison symbol


See Also : if X



1.81   lib library definition




CALLING SEQUENCE :

[xlib]=lib('lib_path')



PARAMETERS :




DESCRIPTION :

lib_path is a character string defining the path of a directory containing functions . This directory must contain the binary files names(i).bin and an additional file names (which contains the names of the functions). After the command lib all the functions of lib_path can be called interactively by Scilab.

Such a binary file, for example foo.bin
can be created by Scilab using the command save(lib_path+'/foo.bin',foo).

Standard Scilab libraries are defined using lib
on SCIDIR/macros/* subdirectories


EXAMPLE :

 deff('[z]=myplus(x,y)','z=x+y')
 deff('[z]=yourplus(x,y)','x=x-y')
are two functions and lib_path is : lib_path='/usr/mymachine/mydirectory'

This directory contains the file names including myplus (first line of the file) and yourplus (second line of the file).

myplus
and yourplus are compiled functions respectively saved in the files

'/usr/mymachine/mydirectory/myplus.bin'

'/usr/mymachine/mydirectory/yourplus.bin'

by the command:
 save(lib_path+'/myplus.bin',myplus)
 save(lib_path+'/yourplus.bin',yourplus)
A library can now be created with the command:
 xlib=lib(lib_path+'/')
xlib is then a Scilab variable which can be saved and loaded in a future session of Scilab or defined on-line or put in the startup file. The functions in this library are known by Scilab which automatically loads them when necessary.


See Also : save X, deff X, getf X, whereis X



1.82   lines rows and columns used for display




CALLING SEQUENCE :

[nl,nc]=lines([n [,nc]])



DESCRIPTION :

lines handles Scilab display paging.

lines()
returns the vector [# columns, # rows] currently used by Scilab for displaying the results.

lines(n)
sets the number of displayed lines (before user is asked for more) to n.

lines(0)
disables vertical paging

lines(n,nc)
changes also the size of the output to nc columns.



1.83   link dynamic link




CALLING SEQUENCE :

link(files, sub-name)
link(files, sub-name, flag)
lst=link('show')
// Link extensions for machines using ``dlopen'' 
// (sun-solaris/linux-elf/alpha/hppa)
x=link(files [, sub-names,flag]);
link(x , sub-names [, flag]);
ulink(x)



PARAMETERS :




DESCRIPTION :

link is a dynamic link facility: this command allows to add new compiled Fortran or C routines to Scilab executable code. Linked routines can be called interactively by the function fort. Linked routines can also be used as "external" for e.g. non linear problem solvers (ode, optim, intg, dassl...). Here are some examples:

The command link('foo.o','foo','f')
links the Fortran object file foo.o with the entry point foo.

The command link('foo.o','foo','c')
links the C object file foo.o with the entry point foo.

The command link('SCIDIR/libs/calelm.a','dcopy')
links the Fortran routine dcopy in the library calelm.a.

A routine can be linked several times and can be unlinked with ulink
. Note that, on some architectures (the ones on which ulink exists) when a routine is linked several times, all the version are kept inside Scilab.

Used with no arguments, link()
returns the current linked routines.

If Scilab is compiled with static link (this is the default for SystemV machines) you may have to include the system libraries in the "link" command.

For example, if foo.o
defines the object code of a routine named foo, you will use link in one the following way:
link('foo.o','foo').
link('foo.o -lm -lc','foo','c').
link('foo.o -lfor -lm -lc','foo').
link('foo.o -lftn -lm -lc','foo').
link('foo.o -L/opt/SUNWspro/SC3.0/lib/lib77 -lm -lc','foo')
If Scilab compiled with the "shared" option, the first example can be used even if a warning for unresolved references is issued.

(Experienced) users may also link
a new Scilab interface routine to add a set of new functions. See Intersci documentation for interface generation and addinter function.


REMARKS :




See Also : fort X, c_link X, addinter X



1.84   list Scilab object and list function definition




CALLING SEQUENCE :

list(a1,....an)  



DESCRIPTION :

Creates a list with elements ai's which are arbitrary Scilab objects (matrix, list,...). Type of list objects is 15.

list()
is the empty list (0 element).

Operations on lists:



EXAMPLE :

 
x=list(1,2,3);
x(4)=10;
x(10)='a'



See Also : null X, tlist X, insertion X, extraction X, size X, length X



1.85   load load saved variable




CALLING SEQUENCE :

load('file-name' [,x1,...,xn])



PARAMETERS :




DESCRIPTION :

The load command can be used to reload in the Scilab session variables previously saved in a file with the save command.

load('file-name')
loads the variables saved in file 'file-name'.

load('file-name','x','y',...,'z')
loads only variables x,y,...,z stored in file 'file-name'.


EXAMPLES :

a=eye(2,2);b=ones(a);
save('vals.dat',a,b);
clear a
clear b
load('vals.dat','a','b');



See Also : save X, getf X



1.86   lsslist Scilab linear state space function definition




CALLING SEQUENCE :

lsslist()
lsslist(a1,....an)  



DESCRIPTION :

lsslist(a1,....an) is a shortcut to to tlist(['lss','A';'B';'C';'X0','dt'], a1,....an)

Creates a tlist with ['lss','A';'B';'C';'X0','dt'] as first entry and ai's as next entries if any. No type nor size checking is done on ai's.




See Also : tlist X, syslin X



1.87   lstcat list concatenation




CALLING SEQUENCE :

lc=lstcat(l1,..ln)



PARAMETERS :




DESCRIPTION :

lc=lstcat(l1,..ln) catenates components of li lists in a single list. If li are other type of variables they are simply added to the resulting list.


EXAMPLE :

lstcat(list(1,2,3),33,list('foo',%s))
lstcat(1,2,3)



See Also : list X



1.88   macro Scilab procedure and Scilab object




DESCRIPTION :

Macros 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.

They can also be defined on-line (see deff
). A file which contains a macro 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 macro is executed. A macro can be compiled for faster execution. Collections of macros can be collected in libraries. Macros which begin with % sign (e.g. %foo) and whose arguments are lists are used to perform specific operations: for example, z=%rmr(x,y) is equivalent to z=x*y when x and z are rationals (i.e. x=list('r',n,d,[]) with n and d polynomials).


See Also : deff X, getf X, comp X, lib X



1.89   matrices Scilab object, matrices in Scilab




DESCRIPTION :

Matrices are basic objects defined in Scilab. They can be defined as follows:
E=[e11,e12,...,e1n;
   e21,e22,...,e2n;
        ....
   em1,em2,...,emn];
Entries eij can be real or complex numbers, polynomials, rationals, strings, booleans.

Vectors are seen as matrices with one row or one column.

syslin
lists in state-space form or transfer matrices can also be defined as above.


EXAMPLES :

E=[1,2;3,4]
E=[%T,%F;1==1,1~=1]
s=poly(0,'s');E=[s,s^2;1,1+s]
E=[1/s,0;s,1/(s+1)]
E=['A11','A12';'A21','A22']



See Also : poly X, string X, boolean X, rational X, syslin X, empty X, hypermatrices X



1.90   matrix reshape a vector or a matrix to a different size matrix




CALLING SEQUENCE :

y=matrix(v,n,m)
y=matrix(v,[sizes])



PARAMETERS :




DESCRIPTION :

For a vector or a matrix with n x m entries y=matrix(v,n,m) or similarily y=matrix(v,[n,m]). transforms the v vector (or matrix) into an nxm matrix by stacking columnwise the entries of v.

For an hypermatrix such as prod(size(v))==prod(sizes)
,y=matrix(v,sizes) (or equivalently y=matrix(v,n1,n2,...nm)) transforms v into an matrix or hypermatrix by stacking columnwise the entries of v. y=matrix(v,sizes) results in a regular matrix if sizes is a scalar or a 2-vector.




See Also : matrices X, hypermatrices X, ones X, zeros X, rand X, poly X, empty X



1.91   max maximum




CALLING SEQUENCE :

[m [,k]]=max(A)
[m [,k]]=max(A,'c') or [m [,k]]=max(A,'r')
[m [,k]]=max(A1,A2,...,An)
[m [,k]]=max(list(A1,A2,...,An))



PARAMETERS :




DESCRIPTION :

For A, a real vector or matrix, max(A) is the largest element A. [m,k]=max(A) gives in addition the index of the maximum. A second argument of type string 'r' or 'c' can be used : 'r' is used to get a row vector m such that m(j) contains the maximum of the j th column of A (A(:,j)), k(j) gives the row indice which contain the maximum for column j. 'c' is used for the dual operation on the rows of A.

m=max(A1,A2,...,An)
, where all the Aj are matrices of the same sizes,returns a vector or a matrix m of size size(m)=size(A1) such that m(i)= max( Aj(i)), j=1,...,n. [m,k]=max(A1,A2,...,An) gives in addition the vector or matrix k. for a fixed i, k(i) is the number of the first Aj(i) achieving the maximum.

[m,k]=max(list(A1,...,An))
is an equivalent syntax of [m,k]=max(A1,A2,...,An)


EXAMPLE :

[m,n]=max([1,3,1])
[m,n]=max([3,1,1],[1,3,1],[1,1,3])
[m,n]=max([3,-2,1],1)
[m,n]=max(list([3,1,1],[1,3,1],[1,1,3]))
[m,n]=max(list(1,3,1))



See Also : sort X, find X, mini X



1.92   maxi maximum




CALLING SEQUENCE :

[m [,k]]=maxi(A)
[m [,k]]=maxi(A,'c') or [m [,k]]=maxi(A,'r')
[m [,k]]=maxi(A1,A2,...,An)
[m [,k]]=maxi(list(A1,A2,...,An))



PARAMETERS :




DESCRIPTION :

For A, a real vector or matrix, maxi(A) is the largest element A. [m,k]=maxi(A) gives in addition the index of the maximum. A second argument of type string 'r' or 'c' can be used : 'r' is used to get a row vector m such that m(j) contains the maximum of the j th column of A (A(:,j)), k(j) gives the row indice which contain the maximum for column j. 'c' is used for the dual operation on the rows of A.

m=maxi(A1,A2,...,An)
, where all the Aj are matrices of the same sizes,returns a vector or a matrix m of size size(m)=size(A1) such that m(i)= max( Aj(i)), j=1,...,n. [m,k]=maxi(A1,A2,...,An) gives in addition the vector or matrix k. for a fixed i, k(i) is the number of the first Aj(i) achieving the maximum.

[m,k]=maxi(list(A1,...,An))
is an equivalent syntax of [m,k]=maxi(A1,A2,...,An)


EXAMPLE :

[m,n]=maxi([1,3,1])
[m,n]=maxi([3,1,1],[1,3,1],[1,1,3])
[m,n]=maxi([3,-2,1],1)
[m,n]=maxi(list([3,1,1],[1,3,1],[1,1,3]))
[m,n]=maxi(list(1,3,1))



See Also : sort X, find X, mini X



1.93   min minimum




CALLING SEQUENCE :

[m [,k]]=min(A)
[m [,k]]=min(A,'c') or [m [,k]]=min(A,'r')
[m [,k]]=min(A1,A2,...,An)
[m [,k]]=min(list(A1,A2,...,An))



PARAMETERS :




DESCRIPTION :

For A, a real vector or matrix, min(A) is the largest element A. [m,k]=min(A) gives in addition the index of the minimum. A second argument of type string 'r' or 'c' can be used : 'r' is used to get a row vector m such that m(j) contains the minimum of the j th column of A (A(:,j)), k(j) gives the row indice which contain the minimum for column j. 'c' is used for the dual operation on the rows of A.

m=min(A1,A2,...,An)
, where all the Aj are matrices of the same sizes,returns a vector or a matrix m of size size(m)=size(A1) such that m(i)= max( Aj(i)), j=1,...,n. [m,k]=min(A1,A2,...,An) gives in addition the vector or matrix k. for a fixed i, k(i) is the number of the first Aj(i) achieving the minimum.

[m,k]=min(list(A1,...,An))
is an equivalent syntax of [m,k]=min(A1,A2,...,An)


EXAMPLE :

[m,n]=min([1,3,1])
[m,n]=min([3,1,1],[1,3,1],[1,1,3])
[m,n]=min(list([3,1,1],[1,3,1],[1,1,3]))
[m,n]=min(list(1,3,1))



See Also : sort X, find X, max X



1.94   mini minimum




CALLING SEQUENCE :

[m [,k]]=mini(A)
[m [,k]]=mini(A,'c') or [m [,k]]=mini(A,'r')
[m [,k]]=mini(A1,A2,...,An)
[m [,k]]=mini(list(A1,A2,...,An))



PARAMETERS :




DESCRIPTION :

For A, a real vector or matrix, mini(A) is the largest element A. [m,k]=mini(A) gives in addition the index of the minimum. A second argument of type string 'r' or 'c' can be used : 'r' is used to get a row vector m such that m(j) contains the minimum of the j th column of A (A(:,j)), k(j) gives the row indice which contain the minimum for column j. 'c' is used for the dual operation on the rows of A.

m=mini(A1,A2,...,An)
, where all the Aj are matrices of the same sizes,returns a vector or a matrix m of size size(m)=size(A1) such that m(i)= max( Aj(i)), j=1,...,n. [m,k]=mini(A1,A2,...,An) gives in addition the vector or matrix k. for a fixed i, k(i) is the number of the first Aj(i) achieving the minimum.

[m,k]=mini(list(A1,...,An))
is an equivalent syntax of [m,k]=mini(A1,A2,...,An)


EXAMPLE :

[m,n]=mini([1,3,1])
[m,n]=mini([3,1,1],[1,3,1],[1,1,3])
[m,n]=mini(list([3,1,1],[1,3,1],[1,1,3]))
[m,n]=mini(list(1,3,1))



See Also : sort X, find X, maxi X



1.95   minus - substraction operator, sign changes




CALLING SEQUENCE  :

 
X-Y
-Y



PARAMETERS :




DESCRIPTION :

Substraction

For numeric operands substraction as its usual meaning. If one of the operands is a matrix and the other one a scalar the the operation is performed element-wise. if Y==[] X
is returned; if X==[] -Y is returned.

Substraction may also be defined for other data types through "soft-coded" operations.


EXAMPLE :

[1,2]-1
[]-2

%s-2
1/%s-2
"cat"+"enate"



See Also : addf X, mtlb_mode X



1.96   mode select a mode in exec file




CALLING SEQUENCE :

mode(k) 



DESCRIPTION :

Used inside an exec-file with the following values for k


See Also : exec X



1.97   mtlb_mode switch Matlab like operations




CALLING SEQUENCE :

mmode=mtlb_mode()
mtlb_mode(mmode)



PARAMETERS :




DESCRIPTION :

Scilab and Matlab additions and substractions work differently when used with empty matrices:


See Also : empty X



1.98   names scilab names syntax




DESCRIPTION :

Names of variables and functions must begin with a letter or one of the following special characters '%', '_', '#', '!', '$', '?'.

Next characters may be letters or digits or any special character in '_
', '#', '!', '$', '?'

Names may be as long as you want but only the first 24 characters are taken into account. Upper and lower case letters are different.




EXAMPLES :

//Valid names
%eps
A1=123
#Color=8
My_Special_Color_Table=rand(10,3)
//Non valid names
//1A , b%, .C

1.99   newfun add a name in the table of functions




CALLING SEQUENCE :

newfun("function-name",nameptr)



DESCRIPTION :

Utility function (for experts only). Adds the name "function-name" in the table of functions known to the interpreter. "nameptr" is an integer 100*fun+fin where fun and fin is the internal coding of the primitive "function-name". This function is useful to associate a primitive to a routine interfaced in "matusr.f" (fun=14). Used with funptr and clearfun one can redefine a primitive by a function with same name.


See Also : clearfun X



1.100   not - logical not




CALLING SEQUENCE :

~A



DESCRIPTION :

~A gives the element-wise negation of the elements of the boolean matrix A.




EXAMPLES :

~[%t %t %f]



See Also : and X, or X, find X



1.101   null delete an element in a list




CALLING SEQUENCE :

l(i)=null()



DESCRIPTION :

Deletion of objects inside a list


EXAMPLE :

l=list(1,2,3);
l(2)=null() // get list(1,3)



See Also : list X, clear X



1.102   ones matrix made of ones




CALLING SEQUENCE :

y=ones(m,n)
y=ones(x)
y=ones()



DESCRIPTION :

Returns a matrix made of ones. Note that ones(3) is ones(a) with a=3 i.e it is NOT a 3x3 matrix!

ones() is eqivalent to ones(1,1).


See Also : eye X, zeros X



1.103   or - logical or




CALLING SEQUENCE :

or(A),  or(A,'*')
or(A,'r'), or(A,1)

or(A,'c'), or(A,2)
A|B



DESCRIPTION :

or(A) gives the or of the elements of the boolean matrix A. or(A) is true (%t) iff at least one entry of A is %t.

y=or(A,'r')
(or, equivalently, y=or(A,1)) is the rowwise or. It returns in each entry of the row vector y the or of the rows of x (The or is performed on the row index : y(j)= or(A(i,j),i=1,m)).

y=or(A,'c')
(or, equivalently, y=or(A,2)) is the columnwise or. It returns in each entry of the column vector y the or of the columns of x (The or is performed on the column index: y(i)= or(A(i,j),j=1,n))).

A
|B gives the element-wise logical or of the booleans matrices A and B .A and B must be matrices with the same dimensions or one from them must be a single boolean.




EXAMPLES :

or([%t %t %f])
[%t %t %f]|[%f %t %t]
[%t %t %f]|%f



See Also : and X, not X, find X



1.104   overloading display, functions and operators overloading capabilities




DESCRIPTION :

In scilab, variable display, functions and operators may be defined for new objects using functions (scilab coded or primitives). for binary operators: %<first_operand_type>_<op_code>_<second_operand_type>

for unary operators: %<operand_type>_<op_code>

extraction and insertion operators which are n-nary operators are described below.

<operand_type>, <first_operand_type>, <second_operand_type> are sequence of characters associated with each data type as described in the following table:

string c
polynomial p
function m
constant s
list l
tlist <tlist_type>
boolean b
sparse sp
boolean sparse spb

<op_code> is a single character associated with each operator as described in the following table:

' t
+ a
- s
* m
/ r
\\ l
^ p
.* x
./ d
.\\ q
.*. k
./. y
.\\. z
: b
.* u
/. v
\\. w
[a,b] c
[a;b] f
() extraction e
() insertion i
== o
<> n
| g
& h
.^ j
~ 5
.' 0
< 1
> 2
<= 3
>= 4

The overloading function for extraction syntax b=a(i1,...,in) has the following calling sequence: b=%<type_of_a>_e_(i1,...,in,a) and the syntax [x1,..,xm]=a(i1,...,in) has the following calling sequence: [x1,..,xm]=%<type_of_a>_e_(i1,...,in,a)

The overloading function associated to the insertion syntax a(i1,...,in)=b has the following calling sequence: a=%<type_of_a>_i_<type_of_b>(i1,...,in,a,b).




See Also : tlist X, disp X, symbols X


EXAMPLES :

//DISPLAY
deff('[]=%tab_p(l)','disp([['' '';l(3)] [l(2);string(l(4))]])')
tlist('tab',['a','b'],['x';'y'],rand(2,2))

//OPERATOR
deff('x=%c_a_s(a,b)','x=a+string(b)')
's'+1

//FUNCTION
deff('x=%c_sin(a)','x=''sin(''+a+'')''')
sin('2*x')

1.105   parents ) - left and right parenthesis




CALLING SEQUENCE :

(expression)
[...]=func(e1,e2,...)
[x1,x2,...]=(e1,e2,...)
x(i,j)
v(i)
[...]=l(i)



PARAMETERS :




DESCRIPTION :

Left and right parenthesis are used to


EXAMPLE :

3^(-1)
x=poly(0,"x");
//
(x+10)/2
i3=eye(3,3)
//
a=[1 2 3;4 5 6;7 8 9],a(1,3),a([1 3],:),a(:,3)
a(:,3)=[]
a(1,$)=33
a(2,[$ $-1])
a(:,$+1)=[10;11;12]
//
w=ssrand(2,2,2);ssprint(w)
ssprint(w(:,1))
ss2tf(w(:,1)) 
//
l=list(1,2,3,4)
[a,b,c,d]=l(:)
l($+1)='new'
//
v=%t([1 1 1 1 1])
//
[x,y,z]=(1,2,3)



See Also : colon X, comma X, brackets X, list X, extraction X, insertion X



1.106   part extraction of strings




CALLING SEQUENCE :

[c]=part(mp,v)



PARAMETERS :




DESCRIPTION :

Let s[k] stands for the k character of string s ( or the empty character if k >length(s)).

part
returns c, a matrix of character strings, such that c(i,j) is the string "s[v(1)]...s[v(n)]" ( s=mp(i,j) ).


EXAMPLE :

c=part(['a','abc','abcd'],[1,1,2])



See Also : string X, length X



1.107   pause pause mode, invoke keyboard




DESCRIPTION :

Switch to the pause mode; inserted in the code of a function, pause interrupts the execution of the function: one receives a prompt symbol which indicates the level of the pause (e.g. -1->). The user is then in a new session in which all the lower-level variables (and in particular all the variable of the function) are available. To return to lower session enter "return"

In this mode, [...]=return(...) returns the variables of the argument (...) to lower session with names in the output [...]. Otherwise, the lower-level variables are protected and cannot be modified.

The pause
is extremely useful for debugging purposes.

This mode is killed by the command "abort"
.


See Also : return X, abort X, quit X, whereami X, where X



1.108   percent - special character




DESCRIPTION :

Some predefined variables begin with %, such as %i (for sqrt(-1)), %inf (for Infinity), %pi (for 3.14...), %T (for the boolean variable "true"),...

In addition, functions whose names begin with %
are special : they are used for coding (extensions of usual) operations .

For example the function %rmr
performs the multiplication (m) operation x*y for x and y rational matrices (r). The coding conventions are given by the readme file in directory SCIDIR/macros/percent.


EXAMPLE :

x1=tlist('x',1,2);
x2=tlist('x',2,3);
deff('x=%xmx(x1,x2)','x=list(''x'',x1(2)*x2(2),x2(3)*x2(3))');
x1*x2

1.109   plus - addition operator




CALLING SEQUENCE  :

 
X+Y
str1+str2



PARAMETERS :




DESCRIPTION :

Addition.

For numeric operands addition as its usual meaning. If one of the operands is a matrix and the other one a scalar the scalar is added to each matrix entries. if one of the operands is an empty matrix the other operand is returned.

For character strings +
means concatenation.

Addition may also be defined for other data types through "soft-coded" operations.


EXAMPLE :

[1,2]+1
[]+2
s=poly(0,"s");
s+2
1/s+2
"cat"+"enate"



See Also : addf X, mtlb_mode X



1.110   poly polynomial definition




CALLING SEQUENCE :

[p]=poly(a,"x", ["flag"])



PARAMETERS :




DESCRIPTION :

If a is a matrix, p is the characteristic polynomial i.e. determinant(x*eye()-a), x being the symbolic variable.

If v
is a vector, poly(v,"x",["roots"]) is the polynomial with roots the entries of v and "x" as formal variable. (In this case, roots and poly are inverse functions).

poly(v,"x","coeff")
creates the polynomial with symbol "x" and with coefficients the entries of v. (Here poly and coeff are inverse functions).

s=poly(0,"s")
is the seed for defining polynomials with symbol "s".


EXAMPLE :

s=poly(0,"s");p=1+s+2*s^2;
A=rand(2,2);poly(A,"x")



See Also : coeff X, matrices X, rational X



1.111   power power operation (^,.^)




CALLING SEQUENCE :

t=A^b
t=A**b
t=A.^b



PARAMETERS :




DESCRIPTION :

Notes:


EXAMPLE :

A=[1 2;3 4];
A^2.5,
A.^2.5
(1:10)^2
(1:10).^2

s=poly(0,'s')
s^(1:10)



See Also : exp X



1.112   predef variable protection




CALLING SEQUENCE :

predef([n])



DESCRIPTION :

Utility function used for defining "predefined" variables. Predefined variables are protected and cannot be killed. They are not saved by the 'save' command.

predef()
sets all the current variables to predefined ones.

predef(n)
sets the max(n,7) last defined variables as predefined.




REMARK :

A number of predefined variables are set in the start-up file scilab.star. These variables are seen by typing who when entering in Scilab.

User may in particular set its own predefined variables in user's startup file home/.scilab



See Also : clear X, save X



1.113   print prints variables in a file




CALLING SEQUENCE :

print('file-name',x1,[x2,...xn]) 



DESCRIPTION :

prints xi on file 'file-name' with the current format, i.e. the format used by scilab to display the variables. All types of variables may be "print"'ed

Note : xi
must be a named variable, with expressions variable name part of the display is unpredictable.

print(%io(2),...)
prints on Scilab's window. this syntax may be used to display variables within a macro.


EXAMPLES :

a=rand(3,3);p=poly([1,2,3],'s');l=list(1,'asdf',[1 2 3]);
print(%io(2),a,p,l)
write(%io(2),a)



See Also : write X, read X, format X, printf X, disp X



1.114   printf Emulator of C language printf function




CALLING SEQUENCE :

printf(format,value_1,..,value_n)



PARAMETERS :




DESCRIPTION :

The printf function converts, formats, and writes its value parameters, under control of the format parameter, to the standard output.

The format
parameter is a character string that contains two types of objects: If any values remain after the entire format has been processed, they are ignored.




EXAMPLES :

printf('Result is:\\nalpha=%f",0.535)



See Also : string X, print X, write X, format X, disp X, file X, fprintf X, sprintf X



1.115   printf_conversion printf, sprintf, fprintf conversion specifications




DESCRIPTION :

Each conversion specification in the printf , sprintf , f printfformat parameter has the following syntax: An optional decimal digit string that specifies the minimum field width. If the converted value has fewer characters than the field width, the field is padded on the left to the length specified by the field width. If the left-adjustment option is specified, the field is padded on the right.

An optional precision. The precision is a .
(dot) followed by a decimal digit string. If no precision is given, the parameter is treated as 0 (zero). The precision specifies:

1


See Also : printf X, fprintf X, sprintf X



1.116   pwd print Scilab current directory




CALLING SEQUENCE :

pwd



DESCRIPTION :

return in ans the Scilab current directory.


EXAMPLE :

pwd



See Also : getcwd X, chdir X, unix X



1.117   quit decrease the pause level or exit




DESCRIPTION :

quit terminates Scilab or decreases the pause level.


See Also : pause X, break X, abort X, exit X



1.118   quote - transpose operator, string delimiter




DESCRIPTION :

quote (')is used for (Conjugate) Transpose of matrix.

quote (.'
)is used for (non Conjugate) Transpose of matrix.

Simple (') or double (") quotes are also used to define character strings. (Character strings are defined between two quotes). A Quote within a character string is denoted by two quotes.




EXAMPLES :

[1+%i, 2]'
[1+%i, 2].'
x='This is a character string'
'He said:''Good'''

1.119   rand random number generator




CALLING SEQUENCE :

rand(m,n [,rtype])
rand(x [, rtype])
rand('key'[,n])
rand()



DESCRIPTION :

random matrix generator. rand() : with no arguments gives a scalar whose value changes each time it is referenced. By default, random numbers are uniformly distributed in the interval (0,1). rand('normal') switches to a normal distribution with mean 0 and variance 1. rand('uniform') switches back to the uniform distribution.

The type of the random generator can also be locally changed by the use of the extra parameter rtype
( which can be 'uniform' or 'normal'


EXAMPLE :

x=rand(10,10,'uniform')
rand('normal')
rand('info')
y=rand(x,'normal');



See Also : ssrand X



1.120   rat Floating point rational approximation




CALLING SEQUENCE :

[N,D]=rat(x [,tol])
y=rat(x [,tol])



PARAMETERS :




DESCRIPTION :

[N,D] = rat(x,tol) returns two integer matrices so that N./D is close tox in the sense that abs(N./D - X) <= tol*abs(x). The rational approximations are generated by truncating continued fraction expansions. tol = 1.e-6*norm(X,1) is the default. y = rat(x,tol) return the quotient N./D


See Also : int X, round X


EXAMPLES :

[n,d]=rat(%pi)
[n,d]=rat(%pi,1.d-12)
n/d-%pi

1.121   rational Scilab objects, rational in Scilab




DESCRIPTION :

A rational r is a quotient of two polynomials r=num/den. The internal representation of a rational is a list. r=tlist('['r','num','den','dt'],num,den,[]) is the same as r=num/den. A rational matrix can be defined with the usual syntax e.g. [r11,r12;r21,r22] is a 2x2 matrix where rij are 1x1 rationals. A rational matrix can also be defined as above as a list tlist(['r','num','den','dt'],num,den,[]) with num and den polynomial matrices.


EXAMPLES :

s=poly(0,'s');
W=[1/s,1/(s+1)]
W'*W
Num=[s,s+2;1,s];Den=[s*s,s;s,s*s];
tlist(['r','num','den','dt'],Num,Den,[])
H=Num./Den
syslin('c',Num,Den)
syslin('c',H)
[Num1,Den1]=simp(Num,Den)



See Also : poly X, syslin X, simp X



1.122   read matrices read




CALLING SEQUENCE :

[x]=read(file-desc,m,n,[format])   
[x]=read(file-desc,m,n,k,format)



PARAMETERS :




DESCRIPTION :

reads row after row the mxn matrix x (n=1 for character chain) in the file file-desc (string or integer). Each row of the matrix x begin in a new line of file-desc file. Depending on format, a given row of the x matrix may be read from more than one line of file-desc file.

The type of the result will depend on the specified format. If format contains only (d,e,f,g)
descriptors the function tries to read numerical data (the result is matrix of real numbers).

If format contains only a
descriptors the function tries to read character strings (the result is a character string column vector). In this case n must be equal to 1.

Examples for format
:
 
(1x,e10.3,5x,3(f3.0))
(10x,a20) 
.LP 
When format is omitted datas are read using numerical free format: 
blank, comma and slash may be used as data separators, n*v may be use
to represent n occurrences of value n.

.LP
A direct access file can be used if using the parameter \fVk\fR which is 
is the vector of record numbers to be read (one record per row),
thus \fVm\fR must be \fVm=prod(size(k))\fR.
.LP
To read on the keyboard use \fVread(%io(1),...)\fR.
.SH REMARK
Last line of data files must be terminated by a newline to be taken
into account.
.SH EXAMPLE
.nf
if MSDOS then unix('del foo');
else unix('rm -f foo'); end
A=rand(3,5); write('foo',A);
B=read('foo',3,5)
B=read('foo',-1,5)
read(%io(1),1,1,'(a)')  // waits for user's input



See Also : file X, readb X, write X, x_dialog X, scanf X



1.123   read4b fortran file binary read




CALLING SEQUENCE :

x=read4b(file-name,m,n [,rec])



PARAMETERS :




DESCRIPTION :

binary read of the matrix x in the file file-name. Matrix entries are supposed to have been stored on 4 byte words.

For direct record access, file must have been previously opened using file
function to set the record_length. file-name must be the result of the file function.


See Also : file X, write X, writb X, binary X, write4b X



1.124   readb fortran file binary read




CALLING SEQUENCE :

x=readb(file-name,m,n [,rec])



PARAMETERS :




DESCRIPTION :

binary read of the matrix x in the file file-name. Matrix entries are supposed to have been stored on 8 byte words.

For direct record access, file must have been previously opened using file
function to set the record_length. file-name must be the result of the file function.


See Also : file X, write X, writb X, binary X, read4b X



1.125   real real part




CALLING SEQUENCE :

[y]=real(x)



PARAMETERS :




DESCRIPTION :

real(x) is the real part of x (See %i to enter complex numbers).


See Also : imag X



1.126   resume return or resume execution and copy some local variables




CALLING SEQUENCE :

resume
[x1,..,xn]=resume(a1,..,an)



PARAMETERS :




DESCRIPTION :

In a function resume stops the execution of the function, [..]=resume(..) stops the execution of the function and put the local variables ai in calling environnement under names xi.

In pause
mode, it allows to return to lower level [..]=resume(..) returns to lower level and put the local variables ai in calling environnement under names xi.

In an execstr
called by a function [..]=resume(..) stops the execution of the function and put the local variables ai in calling environnement under names xi.

resume
is equivalent to return.


See Also : abort X, break X



1.127   return return or resume execution and copy some local variables




CALLING SEQUENCE :

return
[x1,..,xn]=return(a1,..,an)



PARAMETERS :




DESCRIPTION :

In a function return stops the execution of the function, [..]=return(..) stops the execution of the function and put the local variables ai in calling environnement under names xi.

In pause
mode, it allows to return to lower level [..]=return(..) returns to lower level and put the local variables ai in calling environnement under names xi.

In an execstr
called by a function [..]=return(..) stops the execution of the function and put the local variables ai in calling environnement under names xi.

resume
is equivalent to return.


See Also : abort X, break X



1.128   rlist Scilab rational fraction function definition




CALLING SEQUENCE :

rlist()
rlist(a1,....an)  



DESCRIPTION :

rlist(a1,....an) is a shortcut to tlist(['r','num';'den','dt'], a1,....an)

Creates a tlist with ['r','num';'den','dt'] as first entry and ai's as next entries if any. No type nor size checking is done on ai's.




See Also : tlist X, syslin X



1.129   round rounding




CALLING SEQUENCE :

[y]=round(x)



PARAMETERS :




DESCRIPTION :

round(x) rounds the elements of x to the nearest integers.


See Also : int X, floor X, ceil X



1.130   save saving variables




CALLING SEQUENCE :

 
save(file-name [,x1,x2,...,xn])



PARAMETERS :




DESCRIPTION :

The save command can be used to save Scilab current variables in binary form in a file.

save('filename') saves all current variables in the file named filename
.

save('file-name',x,y)
saves only named variables x and y.

Saved variables can be reloaded by the load
command.


EXAMPLES :

a=eye(2,2);b=ones(a);
save('val.dat',a,b);
clear a
clear b
load('val.dat','a','b');



See Also : load X



1.131   scanf Converts formatted input on standard input




CALLING SEQUENCE :

 [v_1,...v_n]=scanf (format);



PARAMETERS :




DESCRIPTION :

The scanf functions get character data on standard input (%io(1)), interpret it according to a format, and returns the converted results.

The format parameter contains conversion specifications used to interpret the input.

The format parameter can contain white-space characters (blanks, tabs, newline, or formfeed) that, except in the following two cases, read the input up to the next nonwhite-space character. Unless there is a match in the control string, trailing white space (including a newline character) is not read.



See Also : printf X, read X, fscanf X, sscanf X



1.132   scanf_conversion scanf, sscanf, fscanf conversion specifications




DESCRIPTION :

Each conversion specification in the format parameter contains the following elements: The conversion specification has the following syntax:

[*][width][size]convcode
.

The results from the conversion are placed in v_i arguments unless you specify assignment suppression with * (asterisk). Assignment suppression provides a way to describe an input field that is to be skipped. The input field is a string of nonwhite-space characters. It extends to the next inappropriate character or until the field width, if specified, is exhausted.

The conversion code indicates how to interpret the input field. You should not specify the v_i parameter for a suppressed field. You can use the following conversion codes:



See Also : scanf X, scanf X, fscanf X



1.133   sciargs scilab command line arguments




CALLING SEQUENCE :

args=sciargs()



DESCRIPTION :

This function returns a vector of character strings containing the arguments of the Scilab command line. First args entry contains the path of the lanched executable file.

This function correspond to the getarg
function in C langage


See Also : getenv X



1.134   scilab Major unix script to execute Scilab and miscellaneous tools




CALLING SEQUENCE :

scilab [-ns -nw -display display -f file]
scilab -help [ <key> ]
scilab -k <key>
scilab -xk <key>
scilab -link <objects>



DESCRIPTION :

For example:
scilab -link  C/interf.o C/evol.o C/bib.a
will create a new scilex file in which the default interf.o file will be replaced by C/interf.o.



1.135   scilink Unix script to relink Scilab




CALLING SEQUENCE :

scilink <object-files>



DESCRIPTION :

This script is used to produce a local scilex (executable code of Scilab) linked with the additional files given by the user in <object-files>.

If in the list of object files some names are known scilex
names (from SCIDIR/routines/default ) then the scilex default files are omitted and replaced with the given ones .

This script also produces an xscilab
script, which when called will ran the new generated scilex file.

For example the command
scilink C/interf.o C/evol.o C/bib.a
will create a new scilex file in which the default interf.o file will be replaced by C/interf.o.


See Also : link X, addinter X



1.136   select select keyword




DESCRIPTION :

 select expr,
   case expr1 then instructions1,
   case expr2 then instructions2,
   ...
   case exprn then instructionsn,
   [else instructions],
 end
Notes:


EXAMPLE :

while %t do
  n=round(10*rand(1,1))
  select n
  case 0 then 
    disp(0)
  case 1 then
    disp(1)
  else
    break
  end
end
  



See Also : if X, while X, for X



1.137   semicolumn - ending expression and row separator




DESCRIPTION :

In a file, the line separator ``;'' suppresses the display of the line.

Within brackets ; denotes row separator in matrix definition.


EXAMPLES :

sin(%pi) sin(%pi); a=[1,2;3 4]



1.138   setbpt setting breakpoints




CALLING SEQUENCE :

setbpt(macro-name [,line-num])



PARAMETERS :




DESCRIPTION :

setbpt interactively inserts a breakpoint in the line number line-num (default value is 1) of the function macro-name

When reaching the breakpoint, Scilab evaluates the specified line , prints the number of the line and the name of the function. If the function is not compiled ( see comp ) the line is printed on the screen. Then Scilab goes into a pause mode in which the user can check current values. The pause is exited with resume or abort. Redefining the function does not clear the breakpoints, the user must explicitly delete breakpoints using delbpt. The maximum number of functions with breakpoints enabled must be less than 20 and the maximum number of breakpoints is set to 100.


See Also : delbpt X, dispbpt X, pause X, resume X



1.139   sign sign function




DESCRIPTION :

X=sign(A) returns the matrix made of the signs of A(i,j).For complex A, sign(A) = A./abs(A). function.


EXAMPLE :

sign(rand(2,3))
sign(1+%i)



See Also : abs X



1.140   signm matrix sign function




DESCRIPTION :

For square and Hermitian matrices X=sign(A) is matrix sign function.


EXAMPLE :

A=rand(4,4);B=A+A';X=sign(B);spec(X)



See Also : sign X



1.141   size size of objects




CALLING SEQUENCE :

y=size(x [,sel])
[nr,nc]=size(x)



PARAMETERS :




DESCRIPTION :

Size of a (constant, polynomial, string, boolean, rational) matrix x, y = 1x2 vector [number of rows, number of columns].

Called with LHS=2, returns nr,nc
= [number of rows, number of columns].

sel
may be used to specify what dimension to get: Size (length) of ordinary list (number of elements). In this case the syntax must be y=size(x)

Caution: if x is a syslin list representing a linear system, y=size(x) returns in y the (row) vector [number of outputs, number if inputs] i.e. the dimension of the corresponding transfer matrix. The syntax [nr,nc]=size(x) is also valid (with (nr,nc)=(y(1),y(2)).

If x
is a syslin list representing a linear system in state-space form, then [nr,nc,nx]=size(x) returns in addition the dimension nx of the A matrix of x.


EXAMPLES :

[n,m]=size(rand(3,2))
[n,m]=size(['a','b';'c','d'])
x=ssrand(3,2,4);[ny,nu]=size(x)
[ny,nu]=size(ss2tf(x))
[ny,nu,nx]=size(x)



See Also : length X, syslin X



1.142   slash - right division and feed back




DESCRIPTION :

Right division. x=A / b is the solution of x*b=A .

b/a = (a'
\b')' .

a ./ b
is the matrix with entries a(i,j)/ b(i,j). If b is scalar (1x1 matrix) this operation is the same as a./b*ones(a). (Same convention if a is a scalar).

Remark that 123./b
is interpreted as (123)./b. In this cases dot is part of the operator, not of the number.

Backslash stands for left division.

System feed back. S=G/.K
evaluates S=G*(eye()+K*G)^(-1) this operator avoid simplification problem.

Remark that G/.5
is interpreted as G/(.5). In such cases dot is part of the number, not of the operator.

Comment //
comments a line i.e lines which begin by // are ignored by the interpreter.


See Also : inv X, percent X, backslash X, ieee X



1.143   sprintf Emulator of C language sprintf function




CALLING SEQUENCE :

str=sprintf(format,value_1,..,value_n)



PARAMETERS :




DESCRIPTION :

The sprintf function converts, formats, and stores its value parameters, under control of the format parameter.

The format
parameter is a character string that contains two types of objects: If there are not enough items for format in the value parameter list, sprintf generate an error. If any values remain after the entire format has been processed, they are ignored.

Note that sprintf is a scilab emulation of C language function build in Scilab. Consequently it is quite slow. Use string whenever it is possible.


EXAMPLES :

fahr=120
sprintf('%3d Fahrenheit = %6.1f Celsius',fahr,(5/9)*(fahr-32)) 




See Also : string X, print X, write X, format X, disp X, file X, printf X, fprintf X



1.144   sscanf Converts formatted input given by a string




CALLING SEQUENCE :

 [v_1,...v_n]=sscanf (string,format)



PARAMETERS :




DESCRIPTION :

The sscanf functions interpret character string according to a format, and returns the converted results.

The format parameter contains conversion specifications used to interpret the input.

The format parameter can contain white-space characters (blanks, tabs, newline, or formfeed) that, except in the following two cases, read the input up to the next nonwhite-space character. Unless there is a match in the control string, trailing white space (including a newline character) is not read.



See Also : printf X, read X, scanf X, fscanf X



1.145   stacksize set scilab stack size




CALLING SEQUENCE :

stacksize(n)
sz=stacksize()



PARAMETERS :




DESCRIPTION :

Scilab stores all variables in a unique stack stk.

stacksize(n)
allows the user to increase or decrease the size of this stack. The maximum allowed size depends on the amount of free memory and swap space available at the time.

This function with the n
argument may only be called at the main prompt; it cannot be called within a scilab function.

sz=stacksize()
returns a 2-vector which contains the current total and used stack size. It can be used everywhere.


See Also : who X



1.146   star - multiplication operator




DESCRIPTION :

Multiplication. Usual meaning. Valid for constant, boolean, polynomial and rational matrices.

Element-wise multiplication is denoted x.*y
. If x or y is scalar (1x1 matrix) .* is the same as *.

Kronecker product is x.*.y



See Also : mulf X



1.147   startup startup file




DESCRIPTION :

The startup files .scilab (in your home directory) and .scilab in your working directory are automatically executed (if present) when Scilab is invoked, in addition with the file scilab.star in the Scilab directory.


REMARK :

Last line of startup file must be terminated by a newline to be taken into account.



1.148   str2code return scilab integer codes associated with a character string




CALLING SEQUENCE :

c=str2code(str)



PARAMETERS :




DESCRIPTION :

Return c such that c(i) is the scilab integer code of part(str,i))


EXAMPLE :

str2code('Scilab')



See Also : code2str X



1.149   string conversion to string




CALLING SEQUENCE :

string(x)
[out,in,text]=string(x)



PARAMETERS :




DESCRIPTION :

converts a matrix into a matrix of strings.

If x
is a function [out,in,text]=string(x) returns three vectors strings : out is the vector of output variables, in is the vector of input variables, and text is the (column) vector of the source code of the function.

If x
is a lib variable, text is a character string column vector. The first element contains the path of library file and the other the name of functions it defines.

Character strings are defined as 'string'
(between quotes) or "string" (between doublequotes); matrices of strings are defined as usual constant matrices.

Concatenation of strings is made by the +
operation.


EXAMPLES :

string(rand(2,2))
deff('y=mymacro(x)','y=x+1')
[out,in,text]=string(mymacro)
x=123.356; 'Result is '+string(x)



See Also : part X, length X, quote X, evstr X, execstr X, strsubst X, strcat X, strindex X, sci2exp X



1.150   strings Scilab Object, character strings




DESCRIPTION :



Strings are defined as 'string'
(between quotes) or "string" (between doublequotes); matrices of strings are defined as usual constant matrices.

Concatenation of two strings is made by a +
: string1+string2.


EXAMPLE :

['this','is'; 'a 2x2','matrix']
"matrix"=="mat"+"rix"



See Also : part X, length X, strcat X



1.151   symbols scilab operator names




DESCRIPTION :

Use the following names to get help on a specific symbol.

operator name in Scilab help
',", .' quote
+ plus
- minus
*,.* star
/, ./, /. slash
\\,.\\,\\. backslash
. dot
=, == equal
<,>,>=,<=,<> less
~ tilda
[ left
] right
() parents
% percent
: column
, comma
; semi
^ hat
.^ power
| or
& and
.*., ./., .\\. kron




See Also : overloading X



1.152   testmatrix generate some particular matrices




CALLING SEQUENCE :

[y]=testmatrix(name,n)



PARAMETERS :




DESCRIPTION :

Create some particular matrices

1.153   then keyword in if-then-else




DESCRIPTION :

Used with if.


See Also : if X



1.154   tilda - logical not




CALLING SEQUENCE :

~m



PARAMETERS :




DESCRIPTION :

~m is the negation of m.



1.155   tlist Scilab object and typed list definition.




CALLING SEQUENCE :

tlist(typ,a1,....an )  



PARAMETERS :




DESCRIPTION :

Creates a typed-list with elements ai's. The typ argument specifies the list type. Such typed-list allow the user to define new operations working on these object through scilab functions. The only difference between typed-list and list is the value of the type (16 instead of 15).

typ(1)
specifies the list type (character string used to define soft coded operations)

if specified typ(i)
may give the i+1th element formal name

Standard Operations on list
work similarly for typed-list: Moreover if typ(2:n+1) are specified, user may point elements by their names

We give below examples where tlist are used.

Linear systems are represented by specific typed-list
e.g. a linear system [A,B,C,D] is represented by the tlist Sys=tlist(['lss';'A';'B';'C';'D';'X0';'dt'],A,B,C,D,x0,'c') and this specific list may be created by the function syslin.

Sys(2) or Sys('A') is the state-matrix and Sys('td') is the time domain

A rational matrix H
is represented by the typed-list H=tlist(['r';'num';'den';'dt'],Num,Den,[]) where Num and Den are two polynomial matrices and a (e.g. continuous time) linear system with transfer matrix H maybe created by syslin('c',H).

H(2) or H('num') is the transfer matrix numerator


See Also : null X, percent X, syslin X, list X



1.156   type variable type




CALLING SEQUENCE :

[i]=type(x)



PARAMETERS :




DESCRIPTION :

type(x) returns an integer which is the type of x as following :


See Also : typeof X



1.157   ulink unlink a dynamically linked shared object




CALLING SEQUENCE :

ulink(x)



DESCRIPTION :

see link


See Also : link X



1.158   unix shell (sh) command execution




CALLING SEQUENCE :

stat=unix(command-name)



PARAMETERS :




DESCRIPTION :

Sends a string command-name to Unix for execution by the sh shell. Standard output and standard errors of the shell command are written in the calling shell. stat gives -1 if unix can't be called (Not enough system memory available) or the sh return code.


EXAMPLE :

unix("ls $SCI/demos");
unix("emacs $SCI/demos/wheel2/Makefile");
deff('wd=pwd()','if MSDOS then unix(''cd>''+TMPDIR+''\path'');..
                else unix(''pwd>''+TMPDIR+''/path'');end..
      wd=read(TMPDIR+''/path'',1,1,''(a)'')')
wd=pwd()



See Also : edit X, manedit X, unix_g X, unix_s X, unix_w X, unix_x X, host X



1.159   unix_g shell (sh) command execution, output redirected to a variable




CALLING SEQUENCE :

rep=unix_g(cmd)



PARAMETERS :




DESCRIPTION :

Sends a string cmd to Unix for execution by the sh shell. The standard output is redirected to scilab variable rep. Unix execution errors are trapped; *NOTE* that only the last shell command error is reported when a list of command separated by ";" is sent: this is not recommended.


EXAMPLE :

if MSDOS then unix_g('dir '+WSCI+'\demos');
else unix_g("ls $SCI/demos"); end
deff('wd=pwd()','if MSDOS then wd=unix_g(''cd'');..
                 else wd=unix_g(''pwd''); end')
wd=pwd()



See Also : edit X, manedit X, unix_s X, unix_w X, unix_x X, unix X



1.160   unix_s shell (sh) command execution, no output




CALLING SEQUENCE :

unix_s(cmd)



PARAMETERS :




DESCRIPTION :

Sends a string cmd to Unix for execution by the sh shell. The standard output is redirected to /dev/null. Unix execution errors are trapped; *NOTE* that only the last shell command error is reported when a list of command separated by ";" is sent: this is not recommended.


EXAMPLE :

if MSDOS then unix_s("del foo");
else unix_s("rm foo"); end



See Also : edit X, manedit X, unix_g X, unix_w X, unix_x X, unix X



1.161   unix_w shell (sh) command execution, output redirected to scilab window




CALLING SEQUENCE :

rep=unix_w(cmd)



PARAMETERS :




DESCRIPTION :

Sends a string cmd to Unix for execution by the sh shell. The standard output is redirected to scilab window. Unix execution errors are trapped; *NOTE* that only the last shell command error is reported when a list of command separated by ";" is sent: this is not recommended.


EXAMPLE :

if MSDOS then unix_w("dir "+WSCI+"\demos");
else unix_w("ls $SCI/demos"); end



See Also : edit X, manedit X, unix_g X, unix_s X, unix_x X, unix X



1.162   unix_x shell (sh) command execution, output redirected to a window




CALLING SEQUENCE :

unix_x(cmd)



PARAMETERS :




DESCRIPTION :

Sends a string cmd to Unix for execution by the sh shell. The standard output is redirected to a xless window. Unix execution errors are trapped; *NOTE* that only the last shell command error is reported when a list of command separated by ";" is sent: this is not recommended.


EXAMPLE :

if MSDOS then unix_x("dir "+WSCI+"\demos");
else unix_x("ls $SCI/demos"); end



See Also : edit X, manedit X, unix_g X, unix_s X, unix_w X, unix X



1.163   user interfacing a fortran routine




CALLING SEQUENCE :

[s_1,s_2,...,s_lhs]=user(e_1,e_2,...,e_rhs)



DESCRIPTION :

With this command it is possible to use an external program as a Scilab command where (s_1,s_2,...,s_lhs) are the output variables and (e_1,e_2,...,e_rhs) are the input variables. To insert this command in Scilab one has to write a few lines in the user fortran subroutine of Scilab. See intersci or the Scilab documentation for more information.


See Also : fort X, link X



1.164   varargin variable numbers of arguments in an input argument list




SYNTAX :

varargin must be the rightmost argument of the function definition input list.


DESCRIPTION :

A function whose input argument list contains varargin must be called with more input arguments than indicated in the input argument list. The calling arguments passed form varargin keyword onwards may then be retrieved within the function in a list named varargin.

Suppose that varargin
keyword is the n th argument of the formal input argument list, then if the function is called with less than n-1 input arguments the varargin list is not defined, if the function is called with n-1 arguments then varargin list is an empty list.

y = function ex(varargin)
may be called with any number of input arguments. Within function ex input arguments may be retrieved in varargin(i) ,i=1:length(varargin)


EXAMPLE :

deff('exampl(a,varargin)',['[lhs,rhs]=argn(0)'
                          'if rhs>=1 then disp(varargin),end'])
exampl(1)
exampl()
exampl(1,2,3)
l=list('a',%s,%t);
exampl(1,l(2:3))



See Also : function X, varargout X, list X



1.165   varargout variable numbers of arguments in an output argument list




SYNTAX :

varargout must be the rightmost argument of the function definition output list.


DESCRIPTION :

A function whose output argument list contains varargout must be called with more output arguments than indicated in the output argument list. The calling arguments passed form varargout keyword onwards are extracted out of the varargout list defined in the function

varagout = function ex()
may be called with any number of output arguments. Within function ex output arguments may be stored in in varargout(i).


EXAMPLE :

deff('varargout=exampl()','varargout=list(1,2,3,4)')

x=exampl()
[x,y]=exampl()
[x,y,z]=exampl()



See Also : function X, varargin X, list X



1.166   varn symbolic variable of a polynomial




CALLING SEQUENCE :

[symb]=varn(p)
[pm]=varn(x,var)



PARAMETERS :




DESCRIPTION :

symb=varn(p) returns in symb the symbolic variable of the polynomial p (i.e. varn(poly(0,'x')) is 'x').

varn(x,'s')
returns a polynomial matrix with same coefficients as x but with 's' as symbolic variable (change of variable name).


EXAMPLE :

s=poly(0,'s');p=[s^2+1,s];
varn(p) is the string 's' and varn(p,'x') is the polynomial matrix [x^2+1,x]


See Also : horner X, poly X



1.167   warning warning messages




CALLING SEQUENCE :

warning('string')



DESCRIPTION :

prints the character string 'string' in a warning message




See Also : error X



1.168   what list the Scilab primitives




DESCRIPTION :

List of low level primitives and commands.



1.169   where get current instruction calling tree




CALLING SEQUENCE :

[linenum,mac]=where()



PARAMETERS :




DESCRIPTION :

returns linenum and mac such as current instruction has been called by the linenum(1) line of function mac(1), mac(1) has been called by the linenum(2) line of function mac(2) and so on

mac(i) is in general the name of a function but it may also be "exec" or "execstr" if instruction lies in ans exec file or an execstr instruction


See Also : whereami X, pause X



1.170   whereami display current instruction calling tree




CALLING SEQUENCE :

whereami()



DESCRIPTION :

Displays calling tree to instruction which contain whereami(). May be uses within pause levels.


EXAMPLE :

deff('y=test(a)',['y=sin(a)+1';
                  'y=t1(y)';
                  'y=y+1'])
deff('y=t1(y)',['y=y^2';'whereami()'])
test(1)



See Also : where X, pause X



1.171   whereis name of library containing a function




CALLING SEQUENCE :

[librname]=whereis(function-name)



DESCRIPTION :

returns as a character string the name of the library containing the function function-name. The path of the library is returned by typing "librname".


See Also : lib X



1.172   while while keyword




DESCRIPTION :

while clause. Must be terminated by "end"

while expr ,instructions,...[,else instructions], end

while expr do instructions,...[,else instructions], end

while expr then instructions,...[,else instructions], end Notes:


EXAMPLE :

e=1; a=1; k=1;
while norm(a-(a+e),1) > %eps, e=e/2; k=k+1; end
e,k



See Also : for X, select X, break X, return X, pause X



1.173   who listing of variables




CALLING SEQUENCE :

who
names=who('get')
[names,mem]=who('get')



DESCRIPTION :

who displays current variable names.

who('get')
Returns current variable names and memory used in double precision worlds.


See Also : whos X



1.174   whos listing of variables in long form




CALLING SEQUENCE :

whos()



DESCRIPTION :

who displays current variable names, types and memory used


See Also : who X



1.175   writb fortran file binary write




CALLING SEQUENCE :

writb(file-name,a [,rec])



PARAMETERS :




DESCRIPTION :

writes in binary format the matrix a in the file 'filename'.. Matrix entries are stored on 4 byte words

For direct record access, file must have been previously opened using file
function to set the record_length. file-name must be the result of the file function.


See Also : file X, readb X, write X, binary X, write4b X



1.176   write write in a formatted file




DESCRIPTION :

write(file-desc,a,[format])
write(file-desc,a,k,format)  



PARAMETERS :




DESCRIPTION :

writes row-by-row a real matrix or a column vector of character strings in a formatted file. Each row of the a argument begin in a new line of file-desc file. Depending on format a given row of the a argument may be written in more than one line of file-desc file.

Format examples : (1x,e10.3,5x,3(f3.0))
, (10x,a20) ;

See a Fortran book for more precision.

Direct access files : x=write(file_desc,a,k,format)
. Here k is the vector of records (one record by row, i.e. m=prod(size(k))

write(%io(2),....)
writes on Scilab's window.


EXAMPLE :

if MSDOS then unix('del asave');
else unix('rm -f asave'); end
A=rand(5,3); write('asave',A); A=read('asave',5,3);
write(%io(2),A,'('' | '',3(f10.3,'' | ''))')
write(%io(2),string(1:10))
write(%io(2),strcat(string(1:10),','))
write(%io(2),1:10,'(10(i2,3x))')

if MSDOS then unix('del foo');
else unix('rm -f foo'); end
write('foo',A)



See Also : file X, writb X, read X, print X, string X, fprintf X, printf X, sprintf X



1.177   write4b fortran file binary write




CALLING SEQUENCE :

write4b(file-name,a [,rec])



PARAMETERS :




DESCRIPTION :

writes in binary format the matrix a in the file 'filename'. Matrix entries are stored on 8 byte words

For direct record access, file must have been previously opened using file
function to set the record_length. file-name must be the result of the file function.


See Also : file X, readb X, write X, binary X, read4b X


Next Contents