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 :
- files
: a character string or a vector of character string contain object files
used to define the new Scilab interface routine (interface code, user
routines or libraries, system libraries).
- spname
: a character string. Name of interface routine entry point
- fcts
: vector of character strings. The name of new Scilab function
implemented in the new interface (in fin the order ).
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 :
- mode,type
: strings.
- n,err,fd
: scalar
- x
: vector
DESCRIPTION :
A set of function to read and write binary files.
The type parameter can be one of the following :
- "l","s","ul","us","d","f","c","uc"
: for reading or writing respectively a long, a short, an unsigned long, an unsigned
short, a double, a float, a char and an unsigned char. The bytes which are
read are automatically swapped if necessary (by checking little-endian status) in
order to produce machine independent binary files ( in little-endian mode).
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
- "ull","uls","ubl","ubs",
: can be used for reading or writing respectively unsigned little-endian long or
short and unsigned big-endian long or short.
- "dx","fx","lx","sx"
: with x=b or x=l can be used for reading or writing
double, float, long or short as big or little endian.
0
- fd
: The fd parameter returned by the function mopen is used as
a file descriptor (it's a positive integer). When specifying the
fd parameter, the value -1 refers to the default file
( i.e the last opened file).
- mode
: The mode parameter can be "rb" for read binary or "wb" for write
binary or "ab" for append.
- mseek
: The function mseek() sets the position of the next input or output operation
on the stream fd. The new position is at
the signed distance given by n bytes from the beginning, from
the current position, or from the end of the file, according to the
flag value which can be 'set', 'cur' or 'end'.
mseek() allows the file position indicator to be set beyond
the end of the existing data in the file. If data is later
written at this point, subsequent reads of data in the gap
will return zero until data is actually written into the
gap. mseek(), by itself, does not extend the size of the
file.
- mtell
: The function mtell() returns the offset of the current byte relative to
the beginning of the file associated with the named stream fd.
- mget
: The function mget is used to get n object of type
type. If end of file is reached before read completion,
only the properly read values will be returned.
- mgetstr
: used to get an array of characters. If EOF is reached before
read completion only the properly read values will be returned.
- meof,clearerr
: The function meof will return a non null value if end of file
has been reached in a previous call to mget or mgetstr.
The function clearerr is used to resets the error indicator and
EOF indicator to zero.
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 :
- x
: a boolean vector or a boolean matrix or a constant matrix
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:
- ~b
: is the element wise negation of boolean b (matrix).
- b1&b2
: is the element wise logical and of b1 and b2 (matrices).
- b1|b2
: is the element wise logical or of b1 and b2 (matrices).
- Boolean variables can be used for indexing matrices or vectors.
For instance a([%T,%F,%T],:) returns the submatrix
made of rows 1 and 3 of a.
Boolean sparse matrices are supported.
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 :
- a11,a12,...
: any matrix (real, polynomial, rational,syslin list ...) with appropriate dimensions
- s1,s2,...
: any possible variable name
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 :
- "ident"
: string.
- xi
: real matrix or string
- pxi, pyi
: integers
- txi, tyi
: character string "d", "r", "i" or "c".
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
- -
with Scilab "link" command (incremental "soft" linking) during the
Scilab session.(see link)
- -
by "hard" re-linking. Writing the routine call within Scilab routine
default/Ex-fort.f, adding the entry point in the file default/Flist and then re_linking Scilab with the command make bin/scilex in main Scilab directory.
0
There are two forms of calling syntax, a short one and a long one.
The short one will give faster code and an easier calling syntax but
one has to write a small (C or Fortran) interface in order to make the
short form possible. The long one make it possible to call a Fortran
routine (or a C one) whitout modification of the code but the syntax is more
complex and the interpreted code slower.
The meaning of each parameter is described now:
1
- "ident"
is the name of the called subroutine.
- x1,...,xn
are input variables (real matrices or strings) sent to the routine,
- px1,...,pxn
are the respective positions of these variables in the calling
sequence of the routine "ident" and
- tx1,...,txn
are their types ("r", "i", "d" and "c" for real (float) , integer, double precision and strings)
- "out"
is a keyword used to separate input variables from output
variables. when this key word is present it is assumes that
the long form will be used and when it is not prsent,
the short form is used.
- [ny1, my1]
are the size (# of rows and columns. For 'c' arguments,m1*n1 is the number of charaters )
of output variables and
- py1, ...
are the positions of output variables (possibly equal to pxi )
in the calling sequence of the routine.
The pyi's integers must be in increasing order.
- "ty1", ...
are the Fortran types of output variables.
The k first output variables are put in y1,..., yk.
0
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 :
- x
: a real matrix
- y
: integer matrix
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 :
- ierr
: an integer, 1 if chdir failed to change directory and 0 elsewhere.
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 :
- str
: a character string
- c
: vector of character integer codes
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 :
- Mp
: polynomial matrix
- v
: integer (row or column) vector of selected degrees
- C
: big matrix of the coefficients
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 :
- :
: Colon. Used in subscripts and loops.
- j:k
is the vector
[j, j+1, ..., k]
(empty if J>K).
- j:d:k
is the vector
[j, j+d, ..., j+m*d]
The colon notation can also be used to pick out selected rows,
columns and elements of vectors and matrices.
- A(:)
is the vector of all the elements of A regarded as a single
column.
- A(:,j)
is the j-th column of A
- A(j:k)
is
[A(j),A(j+1),...,A(k)]
- A(:,j:k)
is
[A(:,j),A(:,j+1),...,A(:,k)]
- A(:)=w
fills the matrix A with entries of w (taken
column by column if w is a matrix).
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 :
- function
: an not compiled scilab function (type 11)
- opt
: integer flag with value 0 (default) or 1.
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 :
- e1,e2,...,
: input variables.
- s1,s2,...,
: output variables.
- text
: matrix of character strings
- opt
: optional character string
1
- 'c'
: function is "compiled" to be more efficient (default)
- 'n'
: function is not "compiled"
0
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 :
- M
: polynomial matrix
- D
: integer matrix
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 :
- n
: integer
- action, option
: strings
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
- "pause"
: a pause is executed when trapping the error. This option is useful
for debugging purposes.
- "continue"
: next instruction in the function or exec files is executed, current
instruction is ignored. This option is useful for error recovery.
- "kill"
: default mode, all intermediate functions are killed, scilab goes
back to the level 0 prompt.
- "stop"
: interrupts the current Scilab session (useful when
Scilab is called from an external program).
1
0
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 :
- Z
: matrix of character strings M or list(M,Subexp)
1
- M
: matrix of character strings
- Subexp
: vector of character strings
0
- H
: matrix
- ierr
: integer, error indicator
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 :
- 0
: the default value
- -1
: nothing is printed
- 1
: echo of each command line
- 2
: prompt --> is printed
- 3
: echoes + prompts
- 4
: stops before each prompt
- 7
: stops + prompts + echoes : useful mode for demos.
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 :
- name
: a character string
- where
: an optional character string with default value 'all'
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 :
- x
: matrix of any possible types
- l
: list variable
- i,j
: indices
- k1,...kn
: indices
DESCRIPTION :
- MATRIX CASE
i and j, can be:
1
- -
real scalars or vectors or matrices with positive elements.
2
- *
r=x(i,j) designs the matrix r such as
r(l,k)=x(int(i(l)),int(j(k))) for l from 1 to size(i,'*') and
k from 1 to size(j,'*').
i (j) Maximum value must be
less or equal to size(x,1) (size(x,2)).
- *
r=x(i) with x a 1x1 matrix designs the matrix r such as
r(l,k)=x(int(i(l)),int(i(k))) for l from 1 to size(i,1) and
k from 1 to size(i,2).
Note that in this case index
i is valid only if all its entries are equal to one.
- *
r=x(i) with x a row vector designs the row vector
r such as r(l)=x(int(i(l))) for l from 1 to
size(i,'*') i Maximum value must be
less or equal to size(x,'*').
- *
r=x(i) with x a matrix with one or more columns designs
the column vector r such as r(l) (l from 1 to
size(i,'*')) designs the int(i(l)) entry of the column
vector formed by the concatenation of the x's columns.
i Maximum value must be
less or equal to size(x,'*').
1
- -
the : symbol which stands for "all elements".
2
- *
r=x(i,:) designs the matrix r such as
r(l,k)=x(int(i(l)),k)) for l from 1 to size(i,'*') and
k from 1 to size(x,2)
- *
r=x(:,j) designs the matrix r such as
r(l,k)=x(l,int(j(k))) for l from 1 to size(r,1) and
k from 1 to size(j,'*').
- *
r=x(:) designs the column vector r formed by the
column concatenations of x columns. It is equivalent to
matrix(x,size(x,'*'),1).
1
- -
vector of boolean. If an index (i or j )is a vector of
booleans it is interpreted as find(i) or respectively find(j)
- -
a polynomial. If an index (i or j )is a vector of
polynomials or implicit polynomial vector it is interpreted as
horner(i,m) or respectively horner(j,n) where m and n are associated x dimensions.
Even if this feature works for all polynomials, it is recommended to
use polynomials in $ for readability.
0
- LIST OR TLIST CASE
If they are present the ki give the path to a sub-list entry of
l data structure. They allow a recursive extraction without
intermediate copies.
The [...]=l(k1)...(kn)(i) and [...]=l(list(k1,...,kn,i)) instructions are interpreted as:
lk1 = l(k1) .. = .. lkn = lkn-1(kn) [...] = lkn(i) And the l(k1)...(kn)(i,j) and l(list(k1,...,kn,list(i,j)) instructions are interpreted as:
lk1 = l(k1) .. = .. lkn = lkn-1(kn) lkn(i,j) i and j, can be:
When path points on more than one list component the instruction must
have as many left hand side arguments as selected components. But if the
extraction syntax is used within a function input calling sequence
each returned list component is added to the function calling sequence.
1
- -
real scalar or vector or matrix with positive elements.
[r1,...rn]=l(i) extracts the i(k) elements from the list
l and store them in rk variable for k from 1 to
size(i,'*')
- -
the : symbol which stands for "all elements".
- -
a vector of booleans. If i is a vector of
booleans it is interpreted as find(i).
- -
a polynomial. If i is a vector of
polynomials or implicit polynomial vector it is interpreted as
horner(i,m) where m=size(l).
Even if this feature works for all polynomials, it is recommended to
use polynomials in $ for readability.
0
- k1,..kn may be :
1
- -
real positive scalar.
- -
a polynomial,interpreted as
horner(ki,m) where m is the corresponding sub-list size.
- - a character string associated with a sub-list entry name.
0
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 :
- A,X
: matrices or syslin lists
- m,n
: integers
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 :
- x,y
: two vectors
- f
: function or character string (for Fortran call)
DESCRIPTION :
Multiple evaluation of a function for one or two arguments
of vector type :
- z=feval(x,f)
returns the vector z defined by
z(i)=f(x(i))
- z=feval(x,y,f)
returns the matrix
z, z(i,j)=f(x(i),y(j))
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 :
- file-name
: string, file name of the file to be opened
- status
: string, The status of the file to be opened
1
- "new"
: file must not exist new file (default)
- "old"
: file must already exists.
- "unknown"
: unknown status
- "scratch"
: file is to be deleted at end of session
0
- access
: string, The type of access to the file
1
- "sequential"
: sequential access (default)
- "direct"
: direct access.
0
- format
: string,
1
- "formatted"
: for a formatted file (default)
- "unformatted"
: binary record.
0
- recl
: integer,is the size of records in bytes when access="direct"
- unit
: integer, logical unit descriptor of the opened file
- err
: integer, error message number (see error), if open fails. If err is
omitted an error message is issued.
- action
: is one of the following strings:
1
- "close"
: closes the file
- "rewind"
: puts the pointer at beginning of file
- "backspace"
: puts the pointer at beginning of last record.
- "last"
: puts the pointer after last record.
0
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 :
- x
: a boolean vector or a boolean matrix or a "standard" matrix
- ii, ir, ic
: integer vectors of indices or empty matrices
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 :
- x
: a real matrix
- y
: integer matrix
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 :
- x
: a real matrix
- y
: integer matrix
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 :
- type
: character string
- long
: integer ( max number of digits (default 10))
DESCRIPTION :
Sets the current printing format with the parameter type ; it is one of the following :
- "v"
: for a variable format (default)
- "e"
: for the e-format.
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 :
- "ident"
: string.
- xi
: real matrix or string
- pxi, pyi
: integers
- txi, tyi
: character string "d", "r", "i" or "c".
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
- -
with Scilab "link" command (incremental "soft" linking) during the
Scilab session.(see link)
- -
by "hard" re-linking. Writing the routine call within Scilab routine
default/Ex-fort.f, adding the entry point in the file default/Flist and then re_linking Scilab with the command make bin/scilex in main Scilab directory.
0
There are two forms of calling syntax, a short one and a long one.
The short one will give faster code and an easier calling syntax but
one has to write a small (C or Fortran) interface in order to make the
short form possible. The long one make it possible to call a Fortran
routine (or a C one) whitout modification of the code but the syntax is more
complex and the interpreted code slower.
The meaning of each parameter is described now:
1
- "ident"
is the name of the called subroutine.
- x1,...,xn
are input variables (real matrices or strings) sent to the routine,
- px1,...,pxn
are the respective positions of these variables in the calling
sequence of the routine "ident" and
- tx1,...,txn
are their types ("r", "i", "d" and "c" for real (float) , integer, double precision and strings)
- "out"
is a keyword used to separate input variables from output
variables. when this key word is present it is assumes that
the long form will be used and when it is not prsent,
the short form is used.
- [ny1, my1]
are the size (# of rows and columns. For 'c' arguments,m1*n1 is the number of charaters )
of output variables and
- py1, ...
are the positions of output variables (possibly equal to pxi )
in the calling sequence of the routine.
The pyi's integers must be in increasing order.
- "ty1", ...
are the Fortran types of output variables.
The k first output variables are put in y1,..., yk.
0
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 :
- format
: a Scilab string. Specifies a character string combining literal characters with conversion
specifications.
- value_i
: Specifies the data to be converted according to the format parameter.
- str
: column vector of character strings
- file
: a Scilab string specifying a file name or a logical unit number (see file)
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:
- Literal characters
: which are copied to the output stream.
- Conversion specifications
: each of which causes zero or more items
to be fetched from the value parameter list. see
printf_conversion for details
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 :
- format
:Specifies the format conversion.
- file
:Specifies the input file name or file number.
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.
- -
Any character except % (percent sign), which must match the next character
of the input stream.
- -
A conversion specification that directs the conversion of the
next input field. see scanf_conversion for details.
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 :
- prot
: integer with possible values 0,1,2
DESCRIPTION :
Scilab functions are variable, funcprot allows the user to specify
what scilab do when such variables are redefined.
1
- *
If prot==0 nothing special is done
- *
If prot==1 scilab issues a warning message when a function is
redefined (default mode)
- *
If prot==1 scilab issues an error when a function is
redefined
0
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 :
- path
: Scilab string. The directory pathname
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 :
- str
: character string specifying environment variable name
rep
: an optional character string. When this optional value
is used, the function getenv returns the value rep when the environment variable str is not found.
- env
: character string which contain the environment variable value
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 :
- filename
: Scilab string.
- opt
: optional character string
1
- "c"
: loaded functions are "compiled" to be more efficient (default)
- "n"
: loaded functions are not "compiled"
0
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 :
- command-name
: A character string containing Unix sh instruction
- stat
: An integer flag
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 :
- dims
: vector of hypermatrix dimensions
- v
: vector of hypermatrix entries (default value zeros(prod(dims),1))
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 :
- mod
: integer scalar whose possible values are 0,1,or 2
DESCRIPTION :
ieee() returns the current floating point exception mode.
- 0: floating point exception produce an error
1: floating point exception produce a warning
2: floating point exception procudes Inf or Nan
-1
ieee(mod) sets 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.
- -
The only constraint is that each then keyword must be on
the same line line as its corresponding if or elseif keyword.
- -
The keyword then can be replaced by a carriage return or a comma.
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 :
- x
: real or complex vector or matrix.
- y
: real vector or matrix.
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 :
- x
: matrix of any kind (constant, sparse, polynomial,...)
- l
: list
- i,j
: indices
- k1,...kn
: indices with integer value
- a
: new entry value
DESCRIPTION :
- MATRIX CASE
i and j, may be:
1
- -
real scalars or vectors or matrices with positive elements.
2
- *
if a is a matrix with dimensions (size(i,'*'),size(j,'*')) x(i,j)=a returns a new x matrix such as
x(int(i(l)),int(j(k)))=a(l,k) for l from 1 to size(i,'*') and
k from 1 to size(j,'*'), other initial entries of x are unchanged.
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,j)=[] kills rows specified by i if j matches all
columns of x or kills columns specified by j if i matches all
rows of x. In other cases x(i,j)=[] produce an error.
- *
x(i)=a with a a vector returns a new x matrix such as
x(int(i(l)))=a(l) for l from 1 to size(i,'*') ,
other initial entries of x are unchanged.
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
- if
x is a 1x1 matrix
a may be a row (respectively a column) vector with dimension
size(i,'*'). Resulting x matrix is a row (respectively a column) vector
- if
x is a row vector
a must be a row vector with dimension size(i,'*')
- if
x is a column vector
a must be a column vector with dimension size(i,'*')
- if
x is a general matrix
a must be a row or column vector with dimension
size(i,'*') and i maximum value cannot exceed size(x,'*'),
2
- *
x(i)=[] kills entries specified by i.
1
-
the : symbol which stands for "all elements".
2
- *
x(i,:)=a is interpreted as x(i,1:size(x,2))=a
- *
x(:,j)=a is interpreted as x(1:size(x,1),j)=a
- *
x(:)=a returns in x the a matrix reshaped
according to x dimensions. size(x,'*') must be equal to size(a,'*')
1
- -
vector of boolean. If an index (i or j )is a vector of
booleans it is interpreted as find(i) or respectively find(j)
- -
a polynomial. If an index (i or j )is a vector of
polynomials or implicit polynomial vector it is interpreted as
horner(i,m) or respectively horner(j,n) where m and n are associated x dimensions.
Even if this feature works for all polynomials, it is recommended to
use polynomials in $ for readability.
0
- LIST OR TLIST CASE
If they are present the ki give the path to a sub-list entry of
l data structure. They allow a recursive extraction without
intermediate copies.
The l(k1)...(kn)(i)=a and l(list(k1,...,kn,i)=a) instructions are interpreted as:
lk1 = l(k1) .. = .. lkn = lkn-1(kn) lkn(i) = a lkn-1(kn) = lkn .. = .. l(k1) = lk1 And the l(k1)...(kn)(i,j)=a and l(list(k1,...,kn,list(i,j))=a instructions are interpreted as:
lk1 = l(k1) .. = .. lkn = lkn-1(kn) lkn(i,j) = a lkn-1(kn) = lkn .. = .. l(k1) = lk1
1
- i may be :
2
- -
a real non negative scalar.
l(0)=a adds an entry on the "left" of the list
l(i)=a sets the i entry of the list l to
a. if i>size(l), l is previously extended with zero
length entries (undefined).
l(i)=null() suppress the ith list entry.
- -
a polynomial. If i is a polynomial it is interpreted as
horner(i,m) where m=size(l).
Even if this feature works for all polynomials, it is recommended to
use polynomials in $ for readability.
1
k1,..kn may be :
- -
real positive scalar.
- -
a polynomial,interpreted as
horner(ki,m) where m is the corresponding sub-list size.
- - a character string associated with a sub-list entry name.
0
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 :
- X
: real matrix
- y
: integer matrix
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:
- C-l
clears the Scilab window
- C-d
deletes the current character
- C-p
calls back the preceding command
- C-n
go to next command line
- C-a
moves the cursor to the beginning of command line.
- C-b
backspace, moves the cursor one character to the left
- C-f
forwards, moves the cursor one character
to the right
- C-k
kills command line from cursor to the end.
- C-y
yank, retrieves killed line.
- !beg
looks for last command line which begins by beg.
- C-c
interrupts Scilab and pause after
carriage return. (Only functions can be interrupted).
Clicking on the stop button enters a C-C.
See Also :
pause
X, read
X, input
X
1.78 left - left bracket
CALLING SEQUENCE :
[a11,a12,...;a21,a22,...;...]
[s1,s2,...]=func(...)
PARAMETERS :
- a11,a12,...
: matrix of any compatibles types with compatibles dimensions
s1,s2,...
: any possible variable name
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 :
- M
: matrix (usual or polynomial or character string) or list
- n
: integer or integer matrix
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
- <>
means "different" (same as ~=)
- <
means "lower than"
- >
means "larger than"
- <=
means lower than or equal to.
- >=
means larger than or equal to
See Also :
if
X
1.81 lib library definition
CALLING SEQUENCE :
[xlib]=lib('lib_path')
PARAMETERS :
- lib_path
: character string
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 :
- files
: a character string or a vector of character strings. ld files used to define the new entry point (compiled routines, user
libraries, system libraries,..)
- sub-name
: a character string. Name of the entry point in files to be
linked.
- sub-names
: a character string or a vector of character strings . Name of the
entry points in files to be linked.
- x
: an integer which gives the id of a shared library linked into Scilab
with a previous call to link.
- flag
: character string 'f' or 'c' for Fortran (default) or C code.
- names
: a vector of character string. Names of dynamically linked entry points.
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 :
- IBM:
For IBM-RS6000 only one program can be dynamically linked.
- Demo:
When running a demo, you may have some trouble with the link due to
slight differences between systems. In this case, you modify the demo by
adding the needed libraries in the link command.
- dlopen:
For machines using dlopen functionality extended command can be used.
a call to link returns an integer which gives the id of the shared
library which is loaded into Scilab. This number can then be used as
the first argument of the link function in order to link additional
function from the linked shared library. The shared library is
removed with the ulink command.
for example to link functions f and g form binary file
test.o the two following command can be used :
link('test.o',['f','g'])
or
x=link('test.o','f');
link(x,'g');
But
link('test.o','f');
link('test.o','g');
will also work but f and g will be loaded from two
different shared libraries and won't be able to share data.
- show:
The command lst=link('show') will report information about
linked shared libraries and linked functions.
The return value of the function lst is 1 or 0.
If the return value is 1 then the extended calling sequence
described as Link extensions for machines using ``dlopen'' are
accepted.
- unlink :
(dlopen version)
If the function f is changed and one wants to link
the new version, it is necessary to use unlink to get rid of
previous loaded versions of the function f
x=link('test.o','f');
// if I need to reload a new definition of f a call to unlink
// is necessary.
ulink(x);
link('test.o','f');
- scilab symbols:
In order to load a symbol from the Scilab code on can use
link("Scilab",['Scilab-entry-point'])
This does not work on all architectures. On some machines, on can
link a Scilab internal function after a first call to link ( with
a default binary file )
link("test.o",['Scilab-entry-point'])
Note that with dld (Linux machine aout) you can use an empty
string
link(" ",['Scilab-entry-point'])
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:
- extraction
: [x,y,z...]=l(v) where v is a vector of indices;
[x,y,z]=l(:) extracts all the elements.
- insertion
: l(i)=a
- deletion
: l(i)=null() removes the i-th element of the list l.
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 :
- file-name
: character string
- xi
: arbitrary Scilab variable name(s) given as strings.
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 :
- li
: list or any other type of variable
- lc
: a list
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 :
- v
: a vector, a matrix or an hypermatrix
- n,m
: integers
- sizes
: vector of integers
y
: a vector matrix or hypermatrix
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 :
- A
: real vector or matrix.
- A1,...,An
: a set of real vectors or matrices, all of the same size or scalar.
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 :
- A
: real vector or matrix.
- A1,...,An
: a set of real vectors or matrices, all of the same size or scalar.
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 :
- A
: real vector or matrix.
- A1,...,An
: a set of real vectors or matrices, all of the same size or scalar.
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 :
- A
: real vector or matrix.
- A1,...,An
: a set of real vectors or matrices, all of the same size or scalar.
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 :
- X
: scalar or vector or matrix of numbers, polynomials or rationals. It
may also be a syslin list
- Y
: scalar or vector or matrix of numbers, polynomials or rationals. It
may also be a syslin list
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
- k=0
: no echo, no prompt, no stop.
- k=-1
: nothing is printed.
- k=1
: an echo is received after each command line.
- k=2
: prompt --> is printed.
- k=3
: there are echoes, prompts, but no stops.
- k=4
: stops before each prompt and waits for a new command line
- k=7
: there are stops, prompts and echoes.
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.
- ones(m,n)
returns a (m,n) matrix full of ones.
- ones(x)
returns a matrix full of ones with the same size that x.
- ones(x)
is also valid for x a syslin list.
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).
- Display
: The display of new objects defined by tlist structure
may be overloaded (the default display is similar to list's
one). The overloading function must have no output argument a single
input argument. It's name is formed as follow %<tlist_type>_p where %<tlist_type> stands for the first entry of the
tlist type component.
- Operators
: Each operator which is not defined for given operands type may be
defined. The overloading function must have a single output argument
and one or two inputs according to the number of operands. The
function name is formed as follow:
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).
- Functions : Some basic primitive function may also be overloaded for new data type. When
such a function is undefined for a particular data types the function
%<type_of_an_argument>_<function_name> is called. User may add in
this called function the definition associated with the input data
types.
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 :
- x
: matrix of any possible type
- v
: row or column vector of any possible type
- l
: list variable
- func
: any function name
- e1,e2,...
: any possible type expression
DESCRIPTION :
Left and right parenthesis are used to
- *
Specify evaluation order within expressions,
- *
Form right-hand-side functions argument list. Within multiple rhs
arguments must be separated by comma.
- *
Select elements within vectors, matrices and lists.
see help on extraction and insertion for more precisions
- *
[x1,x2,...]=(e1,e2,...) is equivalent to x1=e1, x2=e2, ...
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 :
- mp,c
: string matrices
- v
: integer vector.
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 :
- X
: scalar or vector or matrix of numbers, polynomials or rationals. It
may also be a syslin list
- Y
: scalar or vector or matrix of numbers, polynomials or rationals. It
may also be a syslin list
- str1
: a character string, a vector or a matrix of character strings
- str2
: a character string, a vector or a matrix of character strings
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 :
- a
: matrix or real number
- x
: symbolic variable
- "flag"
: string ("roots", "coeff"), default value is "roots".
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 :
- A,t
: scalar, polynomial or rational matrix.
- b
:a scalar, a vector or a scalar matrix.
DESCRIPTION :
- (A:square)^(b:scalar)
: If A is a square matrix and b is a scalar then
A^b is the matrix A to the power b.
- (A:matrix).^(b:scalar)
: If b is a scalar and A a matrix then A.^b is the matrix formed by the element of A to the power b (elementwise power). If A is a vector and b is a scalar then
A^b and A.^b performs the same operation (i.e elementwise power).
- (A:scalar).^(b:matrix)
If A is a scalar and b is a scalar matrix (or vector) A^b and
A.^b are the matrices (or vectors) formed by a^(b(i,j)).
- (A:matrix).^(b:matrix)
If A and b are vectors (matrices) with compatible dimensions
A.^b is the A(i)^b(i) vector (A(i,j)^b(i,j) matrix).
Notes:
- -
For square matrices A^p is computed through successive
matrices multiplications if p is a positive integer, and by
diagonalization if not.
- -
** and ^ operators are synonyms.
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 :
- format
: a Scilab string. Specifies a character string combining literal characters with conversion
specifications.
- value_i
: Specifies the data to be converted according to the format parameter.
- str
: column vector of character strings
- file
: a Scilab string specifying a file name or a logical unit number (see file)
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:
- Literal characters
: which are copied to the output stream.
- Conversion specifications
: each of which causes zero or more items
to be fetched from the value parameter list. see
printf_conversion for details
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:
- -
A % (percent) sign.
- -
Zero or more options, which modify the meaning of the
conversion specification.
The following list contains the option characters and their
meanings:
1
- -
: Left align, within the field, the result of the conversion.
- +
: Begin the result of a signed conversion with a sign (+ or -).
- "space"
: Prefix a space character to the result if the first character of a
signed conversion is not a sign.
If both the (space) and + options appear, the (space) option is
ignored.
- #
: Convert the value to an alternate form.
For c, d, i, s, and u conversions, the # option has no effect.
For o conversion, # increases the precision to force the first
digit of the result to be a 0 (zero).
For x and X conversions, a nonzero result has 0x or 0X
prefixed to it.
For e, E, f, g, and G conversions, the result always
contains a decimal point, even if no digits follow it.
For g and G conversions, trailing zeros are not removed
from the result.
- 0
: Pad to the field width, using leading zeros (following any indication of
sign or base) for d, i, o, u, x,
X, e, E, f, g, and G conversions;
no space padding is performed.
If the 0 and -- (dash) flags both appear, the 0 flag
is ignored.
For d, i, o u, x, and X conversions, if a precision is specified, the 0 flag is also
ignored.
0
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
- -
The minimum number of digits to appear for d, u,
o, x, or X conversions
- -
The number of digits to appear after the decimal point for
e, E, and f conversions
- -
The maximum number of significant digits for g and G conversions
- -
The maximum number of characters to be printed from a string in
an s conversion
0
- -
A character that indicates the type of conversion to be applied:
1
- %
: Performs no conversion. Displays %.
- d,i
:Accepts an integer value and converts it to signed decimal
notation.
The precision specifies the minimum number of digits to appear.
If the value being converted can be represented in fewer digits, it is
expanded with leading zeros.
The default precision is 1.
The result of converting a zero value with a precision of zero is a
null string.
Specifying a field width with a zero as a leading character causes the
field width value to be padded with leading zeros.
- u
:Accepts an integer value and converts it to unsigned decimal
notation.
The precision specifies the minimum number of digits to appear.
If the value being converted can be represented in fewer digits, it is
expanded with leading zeros.
The default precision is 1.
The result of converting a zero value with a precision of zero is a
null string.
Specifying a field width with a zero as the leading character causes the
field width value to be padded with leading zeros.
- o
:Accepts an integer value and converts it to unsigned octal notation.
The precision specifies the minimum number of digits to appear.
If the value being converted can be represented in fewer digits, it is
expanded with leading zeros. The default precision is 1.
The result of converting a zero value with a precision of zero is
a null string.
Specifying a field width with a zero as the leading character causes the
field width value to be padded with leading zeros.
An octal value for field width is not implied.
- x, X
:Accepts an integer value and converts it to unsigned hexadecimal
notation.
The letters ``abcdef'' are used for the x conversion;
the letters ``ABCDEF'' are used for the X conversion.
The precision specifies the minimum number of digits to appear.
If the value being converted can be represented in fewer digits, it is
expanded with leading zeros. The default precision is 1.
The result of converting a zero value with a precision of zero is a
null string.
Specifying a field width with a zero as the leading character causes the
field width value to be padded with leading zeros.
- f
: Accepts a float or double value and converts it to decimal
notation in the format %[--]ddd.ddd.
The number of digits after the decimal point is equal to the precision
specification.
2
- -
If no precision is specified, six digits are output.
- -
If the precision is zero, no decimal point appears and the system
outputs a number rounded to the integer nearest to value.
- -
If a decimal point is output, at least one digit is output before it.
1
- e, E
:Accepts a real and converts it to the
exponential form %[--]d.ddde+/--dd.
There is one digit before the decimal point, and the number of digits
after the decimal point is equal to the precision specification.
2
- -
If no precision is specified,
, six digits are output.
- -
If the precision is zero,
, no decimal point appears.
- -
The E conversion character
produces a number with E instead of e before the exponent.
The exponent always contains at least two digits.
If the value is zero, the exponent is zero.
1
- g, G
: Accepts a real and converts it in
the style of the e, E, or f conversion characters,
with the precision specifying the number of significant digits.
Trailing zeros are removed from the result.
A decimal point appears only if it is followed by a digit.
The style used depends on the value converted.
Style e (E, if G is the flag used) results only if
the exponent resulting from the conversion is less than -4, or if it
is greater or equal to the precision.
- c
:Accepts and displays an integer value converted to a character.
- s
:Accepts a string value and displays
characters from the string to the end or the number of characters indicated by the precision is
reached.
If no precision is specified, all characters up to the end
are displayed.
0
A field width or precision can be indicated by an * (asterisk)
instead of a digit string.
In this case, an integer value parameter supplies the field
width or precision.
The value parameter converted for output is not fetched until
the conversion letter is reached, so the parameters specifying field
width or precision must appear before the value to be converted (if any).
If the result of a conversion is wider than the field width, the field
is expanded to contain the converted result.
The representation of the plus sign depends on whether the
+ or (space) formatting option is specified.
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(m,n)
is a random matrix of dimension mxn.
- rand(a)
is a random matrix of same size as a. rand(a) is complex if
a is a complex matrix
- rand('uniform')
The default random generator is set to a uniform random number generator.
- rand('normal')
The default random generator is set to a Gaussian random number generator.
- rand('seed')
returns the current value of the seed.
- rand('seed',n)
puts the seed to n. (n=0 at first call).
- str=rand('info')
return the type of the default random generator ('uniform' or 'normal')
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 :
- x
: real vector or matrix
- n
: integer vector or matrix
- d
: integer vector or matrix
- y
: real vector or matrix
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 :
- file-desc
: character string specifying the file name or integer value
specifying logical unit (see file).
- m, n
: integers (dimensions of the matrix x). Set m=-1 if you do not know the
numbers of rows, so the whole file is read.
- format : character string, specifies a "Fortran" format. This
character string must begin with a right parenthesis and end with a
left parenthesis. Formats cannot mix floating point or character
edition modes.
- k
: integer or vector of integer
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 :
- file-name
: string or integer
- m, n
: integers (dimensions of the matrix x). Set m=-1 if you do not know the
numbers of rows, so all the file is read
- rec
: vector of positive integers. the selected records for direct access.
This vector size must be equal to the number of rows of desired x.
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 :
- file-name
: string or integer
- m, n
: integers (dimensions of the matrix x). Set m=-1 if you do not know the
numbers of rows, so all the file is read
- rec
: vector of positive integers. the selected records for direct access.
This vector size must be equal to the number of rows of desired x.
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 :
- x
: real or complex vector or matrix
- y
: real matrix
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 :
- x
: real or complex matrix
- y
: integer or complex (with integer real and imag) matrix
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 :
- file-name
: character string
- xi
: arbitrary Scilab variable(s)
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 :
- format
:Specifies the format conversion.
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.
- -
Any character except % (percent sign), which must match the next character
of the input stream.
- -
A conversion specification that directs the conversion of the
next input field. see scanf_conversion for details.
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 character % (percent sign)
- +
The optional assignment suppression character *
- +
An optional numeric maximum field width
- +
A conversion code
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:
- %
:Accepts a single % (percent sign) input at this point; no assignment
is done.
- d, i
:Accepts a decimal integer;
- u
:Accepts an unsigned decimal integer;
- o
:Accepts an octal integer;
- x
:Accepts a hexadecimal integer;
- e,f,g
:Accepts a floating-point number.
The next field is converted accordingly and stored through the corresponding
parameter, which should be a pointer to a float. The input format
for floating-point numbers is a string of digits, with the
following optional characteristics:
1
- +
It can be a signed value.
- +
It can be an exponential value, containing a decimal point followed
by an exponent field, which consists of an E or an e
followed by an (optionally signed) integer.
- +
It can be one of the special values INF, NaN,
0
- s
:Accepts a string of characters.
- c
:character value is expected. The normal skip over white space
is suppressed.
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 :
- scilab [-ns -nw -display display -f path]
: run scilab. If -ns option is present the startup file
SCI/scilab.star is not executed. If -nw option is present then
scilab is not run in an X window. If -f file is present then
file is executed first into Scilab.
- scilab -help <key>
: write on-line documentation about <key> (usually automatically called
by scilab command "help <key>").
Example:
scilab -help plot3d
- scilab -k <key>
: gives the list of Scilab commands containing the
keyword <key> in their description (same as UNIX command man -k)
- scilab -xk <key>
: gives the list of Scilab commands containing the
keyword <key> in their description in a X window.
- scilab -link <objects>
: Is used to produce a local scilex (executable code
of Scilab) linked with the additional files given by the
user in <objects>.
If, in the list of object files, some names are known from
SCIDIR/routines/default, then the scilex default
files are omitted and replaced with the given ones .
This command also produces an xscilab script, which when called
will ran the new generated scilex file.
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:
- -
The only constraint is that each "then" keyword must be on
the same line line as corresponding "case" keyword.
- -
The "keyword "then" can be replaced by a carriage return or a comma.
instructions1 are executed if expr1=expr, etc.
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 :
- macro-name
: string
- line-num
: integer
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 :
- x
: matrix (including transfer matrix) or list or linear system (syslin)
- y
: 1x2 integer vector or integer number
- sel
: a scalar or a character string
- nr,nc
: two integers
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:
- 1 or 'r'
: to get the number of rows
- 2 or 'c'
: to get the number of columns
- 2 or '*'
: to get the product of rows and column numbers
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 :
- format
: a Scilab string. Specifies a character string combining literal characters with conversion
specifications.
- value_i
: Specifies the data to be converted according to the format parameter.
- str
: column vector of character strings
- file
: a Scilab string specifying a file name or a logical unit number (see file)
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:
- Literal characters
: which are copied to the output stream.
- Conversion specifications
: each of which causes zero or more items
to be fetched from the value parameter list. see
printf_conversion for details
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 :
- format
:Specifies the format conversion.
:Specifies the input file name or file number.
- string
:Specifies input to be read.
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.
- -
Any character except % (percent sign), which must match the next character
of the input stream.
- -
A conversion specification that directs the conversion of the
next input field. see scanf_conversion for details.
See Also :
printf
X, read
X, scanf
X, fscanf
X
1.145 stacksize set scilab stack size
CALLING SEQUENCE :
stacksize(n)
sz=stacksize()
PARAMETERS :
- n
: integer, the required stack size given in number of double precision
words
- sz
: 2-vector [total used]
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 :
- str
: a character string
- c
: vector of character integer codes
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 :
- x
: real matrix or function
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 :
- name
: a character string
- n
: integers, matrix size
- y
: n x m matrix
DESCRIPTION :
Create some particular matrices
- testmatrix('magi',n)
: returns a magic square of size n .
- testmatrix('frk',n)
: returns the Franck matrix :
- testmatrix('hilb',n)
: is the inverse of the nxn Hilbert matrix
(Hij= 1/(i+j-1)).
-1
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 :
- typ
: Character string or vector of character strings
- ai
: any Scilab object (matrix, list,string...).
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:
- extraction
: [x,y,z...]=l(v) where v is a vector of indices;
[x,y,z]=l(:) extracts all the elements.
- insertion
: l(i)=a
- deletion
: l(i)=null() removes the i-th element of the tlist l.
- display
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 :
- x
: Scilab object
- i
: integer
DESCRIPTION :
type(x) returns an integer which is the type of x as following :
- 1
: real or complex constant matrix.
- 2
: polynomial matrix.
- 4
: boolean matrix.
- 5
: sparse matrix.
- 10
: matrix of character strings.
- 11
: un-compiled function.
- 13
: compiled function.
- 14
: function library.
- 15
: list.
- 16
: typed list (tlist)
- 128
: pointer
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 :
- command-name
: A character string containing Unix sh instruction
- stat
: An integer flag
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 :
- cmd
: a character string
- rep
: a column vector of character strings
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 :
- cmd
: a character string
- rep
: a column vector of character strings
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 :
- p
: polynomial (or matrix polynomial)
- symb
: character string
- x
: polynomial or polynomial matrix
- var
: symbolic variable (character string)
- pm
: matrix or polynomial matrix
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 :
- linenum
: column vector of integer
- mac
: column vector of strings
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:
- -
The only constraint is that each "then" or "do" keyword must be on
the same line line as "while" keyword.
- -
The "keyword "then" or "do" can be replaced by a carriage return or a comma.
- -
The optional ,else instructions construction allows to gives
instructions which are executed when expr expression becomes false.
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 :
- file-name
: string or integer
- rec
: vector of positive integers. the selected records for direct access.
This vector size must be equal to the number of rows of a
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 :
- file-desc
: character string specifying the file name or integer value
specifying logical unit (see file).
- a
: real matrix or column vector of character strings.
- format
: character string, specifies a "Fortran" format. This
character string must begin with a right parenthesis and end with a
left parenthesis. Formats cannot mix floating point , integer or
character edition modes
- k
: integer vector
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 :
- file-name
: string or integer
- rec
: vector of positive integers. the selected records for direct access.
This vector size must be equal to the number of rows of a
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