Previous Next Contents

3  Utilities and Elementary Functions

3.1   G_make call make or nmake




CALLING SEQUENCE :

Rfiles=G_make(files,dllname)



PARAMETERS :




DESCRIPTION :

On Unix like systems (i.e unix or windows/gcwin32) G_make calls the make utility for building target files and returns the value of files in the variable Rfiles. On windows platforms, (i.e when Scilab was compiled with Microsoft VisualC++). G_make calls the nmake utility for building target dllname and it returns the value of dllname in the variable Rfiles. Of course G_make will work if apropriate Makefiles are provided in the current Scilab directory.

G_make
can be used to provide OS independant call to addinter. and such examples can be found in the directory SCIDIR/examples/addinter-examples
 
files=G_make([TMPDIR+'/ex1cI.o',TMPDIR+'/ex1c.o'],'ex1c.dll');// compilation 
addinter(files,'foobar','foubare'); // link 



See Also : addinter X



3.2   abs absolute value, magnitude




CALLING SEQUENCE :

t=abs(x)



PARAMETERS :




DESCRIPTION :

abs(x) is the absolute value of the elements of x. When x is complex, abs(x) is the complex modulus (magnitude) of the elements of x.


EXAMPLE :

abs([1,%i,-1,-%i,1+%i])

3.3   acos element wise cosine inverse




CALLING SEQUENCE :

t=acos(x)



PARAMETERS :




DESCRIPTION :

The components of vector t are cosine inverse of the corresponding entries of vector x. Definition domain is [-1, 1].

acos
takes values in :
    ] 0,pi[ x ]-inf +inf[
    [0] x [0,+inf] and [pi] x ]-inf,0]   (real x imag)



EXAMPLE :

x=[1,%i,-1,-%i]
cos(acos(x))

3.4   acosh hyperbolic cosine inverse




CALLING SEQUENCE :

[t]=acosh(x)



PARAMETERS :




DESCRIPTION :

the components of vector t are the ArgCosh of the corresponding entries of vector x. Definition domain is ]1,+infinity[. It takes his values in
     ]0,+inf[ x ]-pi,pi] and  [0] x [0,pi]



EXAMPLE :

x=[0,1,%i];
cosh(acosh(x))

3.5   acoshm matrix hyperbolic inverse cosine




CALLING SEQUENCE :

t=acoshm(x)



PARAMETERS :




DESCRIPTION :

acoshm is the matrix hyperbolic inverse cosine of the matrix x. Uses the formula t=logm(x+(x+eye())*sqrtm((x-eye())/(x+eye()))) For non symmetric matrices result may be inaccurate.


EXAMPLE :

A=[1,2;3,4];
coshm(acoshm(A))
A(1,1)=A(1,1)+%i;
coshm(acoshm(A))



See Also : acosh X, logm X, sqrtm X



3.6   acosm matrix wise cosine inverse




CALLING SEQUENCE :

t=acosm(x)



PARAMETERS :




DESCRIPTION :

t are cosine inverse of the x matrix. Diagonalization method is used. For nonsymmetric matrices result may be inaccurate.One has t=-%i*logm(x+%i*sqrtm(eye()-x*x))


EXAMPLE :

A=[1,2;3,4];
cosm(acosm(A))



See Also : acos X, sqrtm X, logm X



3.7   addf symbolic addition




CALLING SEQUENCE :

addf("a","b")



PARAMETERS :




DESCRIPTION :

addf("a","b") returns the character string "a+b". Trivial simplifications such as addf("0","a") or addf("1",2") are performed.


EXAMPLE :

addf('0','1')
addf('1','a')
addf('1','2')
'a'+'b'



See Also : mulf X, subf X, ldivf X, rdivf X, eval X, evstr X



3.8   addmenu interactive button or menu definition




CALLING SEQUENCE :

addmenu(button [,submenus] [,action]) 
addmenu(gwin,button [,submenus] [,action]) 



PARAMETERS :




DESCRIPTION :

The function allows the user to add new buttons or menus in the main window or graphics windows command panels.

If action
is not given the action associated with a button must be defined by a scilab instruction given by the character string variable which name is Actions associated with the kth sub_menu must be defined by scilab instructions stored in the kth element of the character string variable which name is


EXAMPLE :

addmenu('foo')
foo='disp(''hello'')'

addmenu('Hello',['Franck';'Peter'])
Hello=['disp(''hello Franck'')';'disp(''hello Peter'')']

addmenu(0,'Hello',['Franck';'Peter'])
Hello_0=['disp(''hello Franck'')';'disp(''hello Peter'')']

addmenu('Bye',list(0,'French_Bye'))
French_Bye='disp(''Au revoir'')'



See Also : setmenu X, unsetmenu X, delmenu X



3.9   adj2sp converts adjacency form into sparse matrix.




CALLING SEQUENCE :

A = adj2sp(xadj,adjncy,anz) A = adj2sp(xadj,adjncy,anz,mn)


PARAMETERS :

.TP 7
xadj  
:  integer vector of length (n+1).
.TP 7
adjncy
:  integer vector of length nz containing the row indices 
   for the corresponding elements in anz
.TP 7
anz  
:  column vector of length nz, containing the non-zero 
   elements of A
.TP 7
mn
: row vector with 2 entries, \fVmn=size(A)\fR (optional).
.TP 7
A  
:  real or complex sparse matrix (nz non-zero entries)



DESCRIPTION :

\fVsp2adj\fR converts an adjacency form representation of a matrix
into its standard Scilab representation (utility fonction).
\fVxadj, adjncy, anz\fR = adjacency representation of \fVA\fR i.e:
.LP
\fVxadj(j+1)-xadj(j)\fR = number of non zero entries in row j.
\fVadjncy\fR = column index of the non zeros entries 
in row 1, row 2,..., row n.
\fVanz\fR = values of non zero entries in row 1, row 2,..., row n.
\fVxadj\fR is a (column) vector of size n+1 and 
\fVadjncy\fR is an integer (column) vector of size \fVnz=nnz(A)\fR.
\fVanz\fR is a real vector of size \fVnz=nnz(A)\fR.



EXAMPLE :

A = sprand(100,50,.05);
[xadj,adjncy,anz]= sp2adj(A);
[n,m]=size(A);
p = adj2sp(xadj,adjncy,anz,[n,m]);
A-p,



See Also : sp2adj X, spcompack X



3.10   amell Jacobi's am function




CALLING SEQUENCE :

[sn]=amell(u,k) 



PARAMETERS :




DESCRIPTION :

Computes Jacobi's elliptic function am(u,k) where k is the parameter and u is the argument. If u is a vector sn is the vector of the (element wise) computed values. Used in function %sn.


See Also : delip X, %sn X, %asn X



3.11   asin sine inverse




CALLING SEQUENCE :

[t]=asin(x)



PARAMETERS :




DESCRIPTION :

The entries of t are sine inverse of the corresponding entries of x. Definition domain is [-1, 1]. It takes his values in sets
 
  ]-pi/2,pi/2[ x ]-inf,+inf[, -pi/2 x [0,+inf] and 
  pi/2 x ]-inf,0] (real x imag)



EXAMPLE :

A=[1,2;3,4]
sin(asin(A))



See Also : sin X, sinm X, asinm X



3.12   asinh hyperbolic sine inverse




CALLING SEQUENCE :

[t]=asinh(x)



PARAMETERS :




DESCRIPTION :

The entries of t are the hyperbolic sine inverse of the corresponding entries of x. Definition domain is ]-1,i[ It takes his values in sets
 
  ]-inf,inf[ x ]-pi/2,pi/2[, 
  ]-inf,0[ x [-pi/2] and   [0,inf] x [pi/2] (real x imag)



EXAMPLE :

A=[1,2;2,3]
sinh(asinh(A))

3.13   asinhm matrix hyperbolic inverse sine




CALLING SEQUENCE :

t=asinhm(x)



PARAMETERS :




DESCRIPTION :

asinhm is the matrix hyperbolic inverse sine of the matrix x. Uses the formula t=logm(x+sqrtm(x*x+eye())). Results may be not reliable for non-symmetric matrix.


EXAMPLE :

A=[1,2;2,3]
sinhm(asinhm(A))



See Also : asinh X, logm X, sqrtm X



3.14   asinm matrix wise sine inverse




CALLING SEQUENCE :

t=asinm(x)



PARAMETERS :




DESCRIPTION :

t are sine inverse of the x matrix. Diagonalization method is used. For non symmetric matrices result may be inaccurate.


EXAMPLE :

A=[1,2;3,4]
sinm(asinm(A))
asinm(A)+%i*logm(%i*A+sqrtm(eye()-A*A))



See Also : asin X, sinm X



3.15   atan tangent inverse




CALLING SEQUENCE :

[t]=atan(x)



PARAMETERS :




DESCRIPTION :

The components of vector t are the arctangent of the corresponding entries of vector x.

atan(x,y)
is the same as atan(x/y) but y is allowed to be zero.


EXAMPLE :

x=[1,%i,-1,%i]
phasex=atan(imag(x),real(x))



See Also : tan X, ieee X



3.16   atanh hyperbolic tangent inverse




CALLING SEQUENCE :

t=atanh(x)



PARAMETERS :




DESCRIPTION :

The components of vector t are the hyperbolic tangent inverse of the corresponding entries of vector x. Definition domain is ]-1,1[

This function takes values in
     ] inf,inf[ x ]-pi/2,pi/2[
     ]-inf, 0 [ x [-pi/2]
and  ]  0 ,inf[ x [pi/2]



EXAMPLE :

x=[0,%i,-%i]
tanh(atanh(x))

3.17   atanhm matrix hyperbolic tangent inverse




CALLING SEQUENCE :

t=atanhm(x)



PARAMETERS :




DESCRIPTION :

atanhm(x) is the matrix hyperbolic tangent inverse of matrix x. Results may be inaccurate if x is not symmetric.


EXAMPLE :

A=[1,2;3,4];
tanhm(atanhm(A))



See Also : atanh X, tanhm X



3.18   atanm square matrix tangent inverse




CALLING SEQUENCE :

[t]=atanm(x)



PARAMETERS :




DESCRIPTION :

atanm(x) is the matrix arctangent of the matrix x. Result may be not reliable if x is not symmetric.


EXAMPLE :

tanm(atanm([1,2;3,4]))



See Also : atan X



3.19   besseli Modified I sub ALPHA Bessel functions of the first kind.




CALLING SEQUENCE :

 y = besseli(alpha,x)
 y = besseli(alpha,x,ice)



PARAMETERS :




DESCRIPTION :

besseli(alpha,x) computes I sub ALPHA modified Bessel functions of the first kind, for real, non-negative order alpha and argument x. alpha and x may be vectors. The output is m-by-n with m = size(x,'*'), n = size(alpha,'*') whose (i,j) entry is besseli(alpha(j),x(i)).

If ice is equal to 2 exponentialy scaled Bessel functions is computed




EXAMPLE :

besseli(0.5:3,1:4)
besseli(0.5:3,1:4,2)



See Also : besselj X, besselk X



3.20   besselj Modified J sub ALPHA Bessel functions of the first kind.




CALLING SEQUENCE :

 y = besselj(alpha,x)



PARAMETERS :




DESCRIPTION :

besselj(alpha,x) computes J sub ALPHA modified Bessel functions of the first kind, for real, non-negative order alpha and argument x. alpha and x may be vectors. The output is m-by-n with m = size(x,'*'), n = size(alpha,'*') whose (i,j) entry is besselj(alpha(j),x(i)).




EXAMPLE :

besselj(0.5:3,1:4)




See Also : besseli X, besselk X



3.21   besselk Modified K sub ALPHA Bessel functions of the second kind.




CALLING SEQUENCE :

 y = besselk(alpha,x)
 y = besselk(alpha,x,ice)



PARAMETERS :




DESCRIPTION :

besselk(alpha,x) computes K sub ALPHA modified Bessel functions of the second kind, for real, non-negative order alpha and argument x. alpha and x may be vectors. The output is m-by-n with m = size(x,'*'), n = size(alpha,'*') whose (i,j) entry is besselk(alpha(j),x(i)).

If ice is equal to 2 exponentialy scaled Bessel functions is computed




EXAMPLE :

besselk(0.5:3,1:4)
besselk(0.5:3,1:4,2)



See Also : besselj X, besseli X, bessely X



3.22   bessely Modified Y sub ALPHA Bessel functions of the second kind.




CALLING SEQUENCE :

 y = bessely(alpha,x)



PARAMETERS :




DESCRIPTION :

bessely(alpha,x) computes K sub ALPHA modified Bessel functions of the second kind, for real, non-negative order alpha and argument x. alpha and x may be vectors. The output is m-by-n with m = size(x,'*'), n = size(alpha,'*') whose (i,j) entry is bessely(alpha(j),x(i)).




EXAMPLE :

bessely(0.5:3,1:4)



See Also : besselj X, besseli X, besselk X



3.23   bloc2exp block-diagram to symbolic expression




CALLING SEQUENCE :

[str]=bloc2exp(blocd)
[str,names]=bloc2exp(blocd)



PARAMETERS :




DESCRIPTION :

given a block-diagram representation of a linear system bloc2exp returns its symbolic evaluation. The first element of the list blocd must be the string 'blocd'. Each other element of this list (blocd(2),blocd(3),...) is itself a list of one the following types :

list('transfer','name_of_linear_system')
list('link','name_of_link',
               [number_of_upstream_box,upstream_box_port],
               [downstream_box_1,downstream_box_1_portnumber],
               [downstream_box_2,downstream_box_2_portnumber],
               ...)
The strings 'transfer' and 'links' are keywords which indicate the type of element in the block diagram.

Case 1 : the second parameter of the list is a character string which may refer (for a possible further evaluation) to the Scilab name of a linear system given in state-space representation (syslin
list) or in transfer form (matrix of rationals).

To each transfer block is associated an integer. To each input and output of a transfer block is also associated its number, an integer (see examples)

Case 2 : the second kind of element in a block-diagram representation is a link. A link links one output of a block represented by the pair [number_of_upstream_box,upstream_box_port]
, to different inputs of other blocks. Each such input is represented by the pair [downstream_box_i,downstream_box_i_portnumber].

The different elements of a block-diagram can be defined in an arbitrary order.

For example

[1] S1*S2
with unit feedback.

There are 3 transfers S1
(number n_s1=2) , S2 (number n_s2=3) and an adder (number n_add=4) with symbolic transfer function ['1','1'].

There are 4 links. The first one (named 'U'
) links the input (port 0 of fictitious block -1, omitted) to port 1 of the adder. The second and third one link respectively (output)port 1 of the adder to (input)port 1 of system S1, and (output)port 1 of S1 to (input)port 1 of S2. The fourth link (named 'Y') links (output)port 1 of S2 to the output (port 0 of fictitious block -1, omitted) and to (input)port 2 of the adder.
//Initialization
syst=list('blocd'); l=1;
//
//Systems
l=l+1;n_s1=l;syst(l)=list('transfer','S1');  //System 1
l=l+1;n_s2=l;syst(l)=list('transfer','S2');  //System 2
l=l+1;n_adder=l;syst(l)=list('transfer',['1','1']);  //adder
//
//Links
// Inputs  -1 --> input 1
l=l+1;syst(l)=list('link','U',[-1],[n_adder,1]);
// Internal 
l=l+1;syst(l)=list('link',' ',[n_adder,1],[n_s1,1]);
l=l+1;syst(l)=list('link',' ',[n_s1,1],[n_s2,1]);
// Outputs // -1 -> output 1
l=l+1;syst(l)=list('link','Y',[n_s2,1],[-1],[n_adder,2]);
//Evaluation call
w=bloc2exp(syst);
The result is the character string: w=-(s2*s1-eye())s1.

Note that invoked with two output arguments, [str,names]= blocd(syst)
returns in names the list of symbolic names of named links. This is useful to set names to inputs and outputs.
to
[2] second example
//Initialization
syst=list('blocd'); l=1;
//
//System (2x2 blocks plant)
l=l+1;n_s=l;syst(l)=list('transfer',['P11','P12';'P21','P22']);  
//
//Controller
l=l+1;n_k=l;syst(l)=list('transfer','k'); 
//
//Links
l=l+1;syst(l)=list('link','w',[-1],[n_s,1]);
l=l+1;syst(l)=list('link','z',[n_s,1],[-1]);
l=l+1;syst(l)=list('link','u',[n_k,1],[n_s,2]);
l=l+1;syst(l)=list('link','y',[n_s,2],[n_k,1]);
//Evaluation call
w=bloc2exp(syst);
In this case the result is a formula equivalent to the usual one:

P11+P12*invr(eye()-K*P22)*K*P21;



See Also : bloc2ss X


Author : S. S., F. D. (INRIA)



3.24   bloc2ss block-diagram to state-space conversion




CALLING SEQUENCE :

[sl]=bloc2ss(blocd)



PARAMETERS :




DESCRIPTION :

Given a block-diagram representation of a linear system bloc2ss converts this representation to a state-space linear system. The first element of the list blocd must be the string 'blocd'. Each other element of this list is itself a list of one the following types :

list('transfer','name_of_linear_system')
 
list('link','name_of_link',
             [number_of_upstream_box,upstream_box_port],
             [downstream_box_1,downstream_box_1_portnumber],
             [downstream_box_2,downstream_box_2_portnumber],
             ...)
The strings 'transfer' and 'links' are keywords which indicate the type of element in the block diagram.

Case 1 : the second parameter of the list is a character string which may refer (for a possible further evaluation) to the Scilab name of a linear system given in state-space representation (syslin
list) or in transfer form (matrix of rationals).

To each transfer block is associated an integer. To each input and output of a transfer block is also associated its number, an integer (see examples)

Case 2 : the second kind of element in a block-diagram representation is a link. A link links one output of a block represented by the pair [number_of_upstream_box,upstream_box_port]
, to different inputs of other blocks. Each such input is represented by the pair [downstream_box_i,downstream_box_i_portnumber].

The different elements of a block-diagram can be defined in an arbitrary order.

For example

[1] S1*S2
with unit feedback.

There are 3 transfers S1
(number n_s1=2) , S2 (number n_s2=3) and an adder (number n_add=4) with symbolic transfer function ['1','1'].

There are 4 links. The first one (named 'U'
) links the input (port 0 of fictitious block -1, omitted) to port 1 of the adder. The second and third one link respectively (output)port 1 of the adder to (input)port 1 of system S1, and (output)port 1 of S1 to (input)port 1 of S2. The fourth link (named 'Y') links (output)port 1 of S2 to the output (port 0 of fictitious block -1, omitted) and to (input)port 2 of the adder.
//Initialization
syst=list('blocd'); l=1;
//
//Systems
l=l+1;n_s1=l;syst(l)=list('transfer','S1');  //System 1
l=l+1;n_s2=l;syst(l)=list('transfer','S2');  //System 2
l=l+1;n_adder=l;syst(l)=list('transfer',['1','1']);  //adder
//
//Links
// Inputs  -1 --> input 1
l=l+1;syst(l)=list('link','U1',[-1],[n_adder,1]);
// Internal 
l=l+1;syst(l)=list('link',' ',[n_adder,1],[n_s1,1]);
l=l+1;syst(l)=list('link',' ',[n_s1,1],[n_s2,1]);
// Outputs // -1 -> output 1
l=l+1;syst(l)=list('link','Y',[n_s2,1],[-1],[n_adder,2]);
With s=poly(0,'s');S1=1/(s+1);S2=1/s; the result of the evaluation call sl=bloc2ss(syst); is a state-space representation for 1/(s^2+s-1).
to
[2] LFT example
//Initialization
syst=list('blocd'); l=1;
//
//System (2x2 blocks plant)
l=l+1;n_s=l;syst(l)=list('transfer',['P11','P12';'P21','P22']); 
// 
//Controller
l=l+1;n_k=l;syst(l)=list('transfer','k');
// 
//Links
l=l+1;syst(l)=list('link','w',[-1],[n_s,1]);
l=l+1;syst(l)=list('link','z',[n_s,1],[-1]);
l=l+1;syst(l)=list('link','u',[n_k,1],[n_s,2]);
l=l+1;syst(l)=list('link','y',[n_s,2],[n_k,1]);
With
P=syslin('c',A,B,C,D);
P11=P(1,1); 
P12=P(1,2);
P21=P(2,1); 
P22=P(2,2);
K=syslin('c',Ak,Bk,Ck,Dk);
bloc2exp(syst) returns the evaluation the lft of P and K.


See Also : bloc2exp X


Author : S. S., F. D. (INRIA)



3.25   c_link check dynamic link




CALLING SEQUENCE :

c_link('routine-name')
[test,ilib]=c_link('routine-name')
test=c_link('routine-name',num)



DESCRIPTION :

c_links is a boolean function which checks if the routine 'routine-name' is currently linked. This function returns a boolean value true or false. When used with two return values, the function c_link returns a boolean value in test and the number of the shared library which contains 'routine-name' in ilib (when test is true).


EXAMPLE :

if c_link('foo') then link('foo.o','foo');end
// to unlink all the shared libarries which contain foo
a=%t; while a ;[a,b]=c_link('foo'); ulink(b);end



See Also : link X, fort X



3.26   calerf computes error functions.




CALLING SEQUENCE :

y = calerf(x,flag)


PARAMETERS :




DESCRIPTION :

calerf(x,0) computes the error function:
                      /x
     y = 2/sqrt(pi) *|  exp(-t^2) dt
                     /0
calerf(x,1) computes the complementary error function:
                      /inf
     y = 2/sqrt(pi) *|  exp(-t^2) dt
                     /x
     y= 1 - erf(x)
calerf(x,2) computes the scaled complementary error function:
         y=exp(x^2)*erfc(x)~(1/sqrt{pi})*1/x for large x.



EXAMPLE :

deff('y=f(t)','y=exp(-t^2)');
calerf(1,0)
2/sqrt(%pi)*intg(0,1,f)



See Also : erf X, erfc X, calerf X



3.27   cmb_lin symbolic linear combination




CALLING SEQUENCE :

[x]=cmb_lin(alfa,x,beta,y)



DESCRIPTION :

Evaluates alfa*x-beta*y. alfa, beta, x, y are character strings. (low-level routine)


See Also : mulf X, addf X



3.28   conj conjugate




CALLING SEQUENCE :

[y]=conj(x)



PARAMETERS :




DESCRIPTION :

conj(x) is the complex conjugate of x.


EXAMPLE :

x=[1+%i,-%i;%i,2*%i];
conj(x)
x'-conj(x)  //x'  is conjugate transpose

3.29   convstr case conversion




CALLING SEQUENCE :

[y]=convstr(str-matrix, ["flag"]) 



PARAMETERS :




DESCRIPTION :

converts the matrix of strings str-matrix into lower case (for "l" ;default value) or upper case (for "u").


EXAMPLE :

A=['this','is';'my','matrix'];
convstr(A,'u')

3.30   cos cosine function




CALLING SEQUENCE :

[y]=cos(x)



PARAMETERS :




DESCRIPTION :

For a vector or a matrix, cos(x) is the cosine of its elements . For matrix cosine use cosm(X) function.


EXAMPLE :

x=[0,1,%i]
acos(cos(x))



See Also : cosm X



3.31   cosh hyperbolic cosine




CALLING SEQUENCE :

[t]=cosh(x)



PARAMETERS :




DESCRIPTION :

The elements of t are the hyperbolic cosine of the corresponding entries of vector x.


EXAMPLE :

x=[0,1,%i]
acosh(cosh(x))



See Also : cos X, acosh X



3.32   coshm matrix hyperbolic cosine




CALLING SEQUENCE :

t=coshm(x)



PARAMETERS :




DESCRIPTION :

coshm is the matrix hyperbolic cosine of the matrix x. t=(expm(x)+expm(-x))/2. Result may be inaccurate for nonsymmetric matrix.


EXAMPLE :

A=[1,2;2,4]
acoshm(coshm(A))



See Also : cosh X, expm X



3.33   cosm matrix cosine function




CALLING SEQUENCE :

t=cosm(x)



PARAMETERS :




DESCRIPTION :

cosm(x) is the matrix cosine of the x matrix. t=0.5*(expm(%i*x)+expm(-%i*x)).


EXAMPLE :

A=[1,2;3,4]
cosm(A)-0.5*(expm(%i*A)+expm(-%i*A))



See Also : cos X, expm X



3.34   cotg cotangent




CALLING SEQUENCE :

[t]=cotg(x)



PARAMETERS :




DESCRIPTION :

The elements of t are the cotangents of the corresponding entries of x. t=cos(x)./sin(x)


EXAMPLE :

x=[1,%i];
cotg(x)-cos(x)./sin(x)



See Also : tan X



3.35   coth hyperbolic cotangent




CALLING SEQUENCE :

[t]=coth(x)



DESCRIPTION :

the elements of vector t are the hyperbolic cotangent of elements of the vector x.


EXAMPLE :

x=[1,2*%i]
t=exp(x);
(t-ones(x)./t).\\(t+ones(x)./t)
coth(x)



See Also : cotg X



3.36   cothm matrix hyperbolic cotangent




CALLING SEQUENCE :

[t]=cothm(x)



DESCRIPTION :

cothm(x) is the matrix hyperbolic cotangent of the square matrix x.


EXAMPLE :

A=[1,2;3,4];
cothm(A)



See Also : coth X



3.37   cumprod cumulative product




CALLING SEQUENCE :

y=cumprod(x)
y=cumprod(x,'r') or y=cumprod(x,1) 
y=cumprod(x,'c') or y=cumprod(x,2) 



PARAMETERS :




DESCRIPTION :

For a vector or a matrix x, y=cumprod(x) returns in y the cumulative product of all the entries of x taken columnwise.

y=cumprod(x,'c')
(or, equivalently, y=cumprod(x,2)) returns in y the cumulative elementwise product of the columns of x: y(i,:)=cumprod(x(i,:))

y=cumprod(x,'r') (or, equivalently, y=cumprod(x,2)) returns in y the cumulative elementwise product of the rows of x: y(:,i)=cumprod(x(:,i)).


EXAMPLE :

A=[1,2;3,4];
cumprod(A)
cumprod(A,'r')
cumprod(A,'c')
rand('seed',0);
a=rand(3,4);
[m,n]=size(a);
w=zeros(a);
w(1,:)=a(1,:);
for k=2:m;w(k,:)=w(k-1,:).*a(k,:);end;w-cumprod(a,'r')



See Also : cumprod X, sum X



3.38   cumsum cumulative sum




CALLING SEQUENCE :

y=cumsum(x)
y=cumsum(x,'r') or y=cumsum(x,1)
y=cumsum(x,'c') or y=cumsum(x,2)



PARAMETERS :




DESCRIPTION :

For a vector or a matrix x, y=cumsum(x) returns in y the cumulative sum of all the entries of x taken columnwise.

y=cumsum(x,'c')
(or, equivalently, y=cumsum(x,2)) returns in y the cumulative sum of the columns of x: y(i,:)=cumsum(x(i,:))

y=cumsum(x,'r') (or, equivalently, y=cumsum(x,1)) returns in y the cumulative sum of the rows of x: y(:,i)=cumsum(x(:,i))


EXAMPLE :

A=[1,2;3,4];
cumsum(A)
cumsum(A,'r')
cumsum(A,'c')
a=rand(3,4)+%i;
[m,n]=size(a);
w=zeros(a);
w(1,:)=a(1,:);
for k=2:m;w(k,:)=w(k-1,:)+a(k,:);end;w-cumsum(a,'r')



See Also : cumprod X, sum X



3.39   debug debugging level




CALLING SEQUENCE :

debug(level-int)



PARAMETERS :




DESCRIPTION :

For the values 0,1,2,3,4 of level-int , debug defines various levels of debugging. (For Scilab experts only).



3.40   dec2hex hexadecimal representation of integers




CALLING SEQUENCE :

h=dec2hex(d)



PARAMETERS :




DESCRIPTION :

dec2hex(x) returns the hexadecimal representation of a matrix of integers




EXAMPLE :

dec2hex([2748 10;11 3])

3.41   delip elliptic integral




CALLING SEQUENCE :

[r]=delip(x,ck) 



PARAMETERS :




DESCRIPTION :

returns the value of the elliptic integral with parameter ck :
r=integral from 0 to x {dt / sqrt((1-t^2)*(1-ck^2*t^2))}
x real and positive. When called with x a real vector r is evaluated for each entry of x.


EXAMPLE :

ck=0.5;
delip([1,2],ck)
deff('y=f(t)','y=1/sqrt((1-t^2)*(1-ck^2*t^2))')
intg(0,1,f)    //OK since real solution!



See Also : amell X, %asn X, %sn X



3.42   delmenu interactive button or menu deletion




CALLING SEQUENCE :

delmenu(button) 
delmenu(gwin,button)



PARAMETERS :




DESCRIPTION :

The function allows the user to delete buttons or menus create by addmenu in the main or graphics windows command panels.

If possible, it is better to delete first the latest created button for a given window to avoid gaps in command panels.


EXAMPLE :

addmenu('foo')
delmenu('foo')



See Also : setmenu X, unsetmenu X, addmenu X



3.43   demos guide for scilab demos




CALLING SEQUENCE :

demos()



DESCRIPTION :

demos() is an interactive guide to execute various scilab demonstrations The source code of each demo is in the directory SCIDIR/demos/...



3.44   diag diagonal including or extracting




CALLING SEQUENCE :

[y]=diag(vm, [k])



PARAMETERS :




DESCRIPTION :

for vm a (row or column) n-vector diag(vm) returns a diagonal matrix with entries of vm along the main diagonal.

diag(vm,k)
is a (n+abs(k))x(n+abs(k)) matrix with the entries of vm along the kth diagonal. k=0 is the main diagonal k>0 is for upper diagonals and k<0 for lower diagonals.

For a matrix vm
, diag(vm,k) is the column vector made of entries of the kth diagonal of vm. diag(vm) is the main diagonal of vm. diag(diag(x)) is a diagonal matrix.

To construct a diagonal linear system, use sysdiag
.

Note that eye(A).*A
returns a diagonal matrix made with the diagonal entries of A. This is valid for any matrix (constant, polynomial, rational, state-space linear system,...).

For example
diag(-m:m) +  diag(ones(2*m,1),1) +diag(ones(2*m,1),-1)
gives a tri-diagonal matrix of order 2*m+1


EXAMPLE :

diag([1,2])
A=[1,2;3,4];
diag(A)
diag(A,1)



See Also : sysdiag X



3.45   dlgamma derivative of gammaln function.




CALLING SEQUENCE :

 y = dlgamma(x)



PARAMETERS :




DESCRIPTION :

dlgamma(x) evaluates the derivative of gammaln function at all the elements of x. x must be real.




EXAMPLE :

dlgamma(0.5)




See Also : gamma X, gammaln X



3.46   edit function editing




CALLING SEQUENCE :

newname=edit(functionname [, editor])



PARAMETERS :




DESCRIPTION :

If functionname is the name of a defined scilab function edit(functionname ,[editor]) try to open the associated file functionname.sci. If this file can't be modified edit first create a copy of this file in the TMPDIR directory.

If functionname is the name of a undefined scilab function edit
create a functionname.sci file in the TMPDIR directory.

When leaving the editor the modified or defined function is loaded into Scilab under the name newname
.

The editor character string can be used to specify your favourite text editor.

Default editor is Emacs. This function should be customized according to your needs.


EXAMPLE :

//newedit=edit('edit')  //opens editor with text of this function
//myfunction=edit('myfunction')  //opens editor for a new function



See Also : manedit X



3.47   emptystr zero length string




CALLING SEQUENCE :

s=emptystr()        
s=emptystr(a)        
s=emptystr(m,n)        



PARAMETERS :




DESCRIPTION :

Returns a matrix of zero length character strings

With no input argument returns a zero length character string.

With a matrix for input argument returns a zero length character strings matrix of the same size.

With two integer arguments returns a mxn zero length character strings matrix


EXAMPLE :

x=emptystr();for k=1:10, x=x+','+string(k);end



See Also : part X, length X, string X



3.48   erf The error function.




CALLING SEQUENCE :

 y = erf(x)



PARAMETERS :




DESCRIPTION :

erf computes the error function:
                      /x
     y = 2/sqrt(pi) *|  exp(-t^2) dt
                     /0



EXAMPLE :

deff('y=f(t)','y=exp(-t^2)');
erf(0.5)-2/sqrt(%pi)*intg(0,0.5,f)



See Also : erfc X, erfcx X, calerf X



3.49   erfc The complementary error function.




CALING SEQUENCE :

 y = erfc(x)



PARAMETERS :




DESCRIPTION :

erfc computes the complementary error function:
                      /inf
     y = 2/sqrt(pi) *|  exp(-t^2) dt
                     /x
     y= 1 - erf(x)



EXAMPLE :

erf([0.5,0.2])+erfc([0.5,0.2])



See Also : erf X, erfcx X, calerf X



3.50   erfcx scaled complementary error function.




CALING SEQUENCE :

 y = erfcx(x)



PARAMETERS :




DESCRIPTION :

erfcx computes the scaled complementary error function:
         y = exp(x^2) * erfc(x) ~ (1/sqrt(pi)) * 1/x for large x.



See Also : erf X, erfc X, calerf X



3.51   eval evaluation of a matrix of strings




CALLING SEQUENCE :

[H]= eval(Z)



DESCRIPTION :

returns the evaluation of the matrix of character strings Z.


EXAMPLE :

a=1; b=2; Z=['a','sin(b)'] ; eval(Z)  //returns the matrix [1,0.909];



See Also : evstr X, execstr X



3.52   execstr scilab instructions execution by evaluation of strings




CALLING SEQUENCE :

execstr(instr)
ierr=execstr(instr,'errcatch')



PARAMETERS :




DESCRIPTION :

executes the Scilab instructions given in argument instr If an error is encountered while executing instructions defined in instr, if 'errcatch' flag is present execstr issues an error message, abort execution of the instr instructions and resume with ierr equal to the error number,if 'errcatch' flag is not present, standard error handling works.




EXAMPLE :

execstr('a=1') // sets a=1.
execstr('1+1') // does nothing (while evstr('1+1') returns 2)

execstr(['if %t then';
         '  a=1';
         '  b=a+1';
         'else'
         ' b=0'
         'end'])

execstr('a=zzzzzzz','errcatch')



See Also : evstr X



3.53   full sparse to full matrix conversion




CALING SEQUENCE :

X=full(sp)



PARAMETERS :




DESCRIPTION :

X=full(sp) converts the sparse matrix sp into its full representation. (If sp is already full then X equals sp).


EXAMPLE :

sp=sparse([1,2;5,4;3,1],[1,2,3]);
A=full(sp)



See Also : sparse X, sprand X, speye X





3.54   gamma The gamma function.




CALLING SEQUENCE :

 y = gamma(x)



PARAMETERS :




DESCRIPTION :

gamma(x) evaluates the gamma function at all the elements of x. x must be real.
     /inf
y=  |  t^(x-1) exp(-t) dt
    /0
gamma(n+1) = n!


EXAMPLE :

gamma(0.5)
gamma(6)-prod(1:5)



See Also : gammaln X, dlgamma X



3.55   gammaln The logarithm of gamma function.




CALLING SEQUENCE :

 y = gammaln(x)



PARAMETERS :




DESCRIPTION :

gammaln(x) evaluates the logarithm of gamma function at all the elements of x, avoiding underflow and overflow. x must be real.




EXAMPLE :

gammaln(0.5)




See Also : gamma X, dlgamma X



3.56   getvalue xwindow dialog for data acquisition




CALLING SEQUENCE :

[ok,x1,..,x14]=getvalue(desc,labels,typ,ini)



PARAMETERS :




DESCRIPTION :

This function encapsulate x_mdialog function with error checking, evaluation of numerical response, ...


REMARKS :

All valid expressions can be used as answers; for matrices and vectors getvalues automatically adds [ ] around the given answer before numeric evaluation.


EXAMPLE :

labels=["magnitude";"frequency";"phase    "];
[ok,mag,freq,ph]=getvalue("define sine signal",labels,...
     list("vec",1,"vec",1,"vec",1),["0.85";"10^2";"%pi/3"])



See Also : x_mdialog X, x_matrix X, x_dialog X


Author : S. Steer



3.57   gsort decreasing order sorting




CALLING SEQUENCE :

[s, [k]]=gsort(v )
[s, [k]]=gsort(v,flag1)
[s, [k]]=gsort(v,flag1,flag2)



PARAMETERS :




DESCRIPTION :

gsort is similar to sort with additional properties. The third argument can be used to chose between increasing or decreasing order. The second argument can be used for lexical orders.

[s,k]=gsort(a,'g')
and [s,k]=gsort(a,'g','d') are the same as [s,k]=gsort(a). They perform a sort of the entries of matrix a, a being seen as the stacked vector a(:) (columnwise). [s,k]=gsort(a,'g','i') performs the same operation but in increasing order.

[s,k]=gsort(a,'lr')
sort the rows of the matrix int(a) ( if a is a real matrix) or a (if a is a character string matrix) in lexical decreasing order. s is obtained by a permutation of the rows of matrix int(a) (or a) given by the column vector k) in such a way that the rows of s verify s(i,:) > s(j,:) if i<j. [s,k]=gsort(a,'lr','i') performs the same operation for increasing lexical order

[s,k]=gsort(a,'lc')
sort the columns of the matrix int(a) ( if a is a real matrix) or a (if a is a character string matrix) in lexical decreasing order. s is obtained by a permutation of the columns of matrix int(a) (or a) given by the row vector k) in such a way that the columns of s verify s(:,i) > s(:,j) if i<j. [s,k]=gsort(a,'lc','i') performs the same operation for increasing lexical order


EXAMPLE :

alr=[1,2,2;
     1,2,1;
     1,1,2;
     1,1,1];
[alr1,k]=gsort(alr,'lr','i')
[alr1,k]=gsort(alr,'lc','i')



See Also : find X



3.58   halt stop execution




CALLING SEQUENCE :

halt()



DESCRIPTION :

stops execution until something is entered in the keyboard.


See Also : pause X, return X, exec X



3.59   havewindow return scilab window mode




CALLING SEQUENCE :

havewindow() 



DESCRIPTION :

returns %t if scilab has it own window and %f if not, i.e. if scilab has been invoked by "scilab -nw". (nw stands for "no-window".



3.60   hex2dec converts hexadecimal representation of integers to numbers




CALLING SEQUENCE :

d=hex2dec(h)



PARAMETERS :




DESCRIPTION :

hex2dec(x) returns the matrix of numbers corresponding to the hexadecimal representation.


EXAMPLE :

hex2dec(['ABC','0','A'])

3.61   input prompt for user input




CALLING SEQUENCE :

[x]=input(message,["string"])   



PARAMETERS :




DESCRIPTION :

input(message) gives the user the prompt in the text string and then waits for input from the keyboard.

The input can be expression which is evaluated by evstr
.

Invoked with two arguments, the output is a character string which is the expression entered at keyboard.


EXAMPLE :

//x=input("How many iterations?")
//x=input("What is your name?","string")



See Also : file X, read X, write X, evstr X, x_dialog X, x_mdialog X



3.62   integrate integration by quadrature




CALLING SEQUENCE :

[x]=integrate(expr,v,x0,x1 [,ea [,er]])



PARAMETERS :




DESCRIPTION :

computes :
                      /x1
                     [
                 x = I  f(v)dv
                     ]
                    /x0



EXAMPLE :

integrate('sin(x)','x',0,%pi)
integrate(['if x==0 then 1,';
           'else sin(x)/x,end'],'x',0,%pi)



See Also : intg X



3.63   interp interpolation




CALLING SEQUENCE :

[f0 [,f1 [,f2 [,f3]]]]=interp(xd,x,f,d)



PARAMETERS :




DESCRIPTION :

given three vectors (x,f,d) defining a spline function (see splin) with fi=S(xi), di = S'(xi) this function evaluates S (resp. S', S'', S''') at xd(i). f1 = [S'(xd(1)),S'(xd(2)),...]

f2 = [S''(xd(1)),S''(xd(2)),...]




See Also : splin X, smooth X, interpln X



3.64   interpln linear interpolation




CALLING SEQUENCE :

[y]=interpln(xyd,x)  



PARAMETERS :




DESCRIPTION :

given xyd a set of points in the xy-plane which increasing abscissae and x a set of abscissae, this function computes y the corresponding y-axis values by linear interpolation.


EXAMPLE :

x=[1 10 20 30 40];
y=[1 30 -10 20 40];
plot2d(x',y',[-3],"011"," ",[-10,-40,50,50]);
yi=interpln([x;y],-4:45);
plot2d((-4:45)',yi',[3],"000");



See Also : splin X, interp X, smooth X



3.65   intsplin integration of experimental data by spline interpolation




CALLING SEQUENCE :

v = intsplin([x,] s)



PARAMETERS :




DESCRIPTION :

computes :
                      /x1
                     [
                 v = I  f(x)dx
                     ]
                    /x0
Where f is a function described by a set of experimental value: s(i)=f(x(i)) and x0=x(1), x1=x(n)

Between mesh points function is interpolated using spline's.


EXAMPLE :

t=0:0.1:%pi
intsplin(t,sin(t))



See Also : intg X, integrate X, inttrap X, splin X



3.66   inttrap integration of experimental data by trapezoidal interpolation




CALLING SEQUENCE :

v = inttrap([x,] s)



PARAMETERS :




DESCRIPTION :

computes :
                      /x1
                     [
                 v = I  f(x)dx
                     ]
                    /x0
v = ó
õ
x1


x0
f(x)dx
Where f is a function described by a set of experimental value: s(i)=f(x(i)) and x0=x(1), x1=x(n)

Between mesh points function is interpolated linearly.


EXAMPLE :

t=0:0.1:%pi
inttrap(t,sin(t))



See Also : intg X, integrate X, intsplin X, splin X



3.67   isdef check variable existence




CALLING SEQUENCE :

isdef(name [,where])



PARAMETERS :




DESCRIPTION :

isdef(name) returns %T if the variable 'var-name' exists and %F otherwise.

isdef(name,'local')
returns %T if the variable 'var-name' exists in the local environment of the current function and %F otherwise.




EXAMPLE :

A=1;
isdef('A')
clear A
isdef('A')



See Also : exists X, whereis X, type X, typeof X, clear X



3.68   isinf check for infinite entries




CALLING SEQUENCE :

r=isinf(x)



PARAMETERS :




DESCRIPTION :

isinf(x) returns a boolean vector or matrix which contains true entries corresponding with infinite x entries and false entries corresponding with finite x entries.


EXAMPLE :

isinf([1 0.01 -%inf %inf])



See Also : isnan X



3.69   isnan check for "Not a Number" entries




CALLING SEQUENCE :

r=isnan(x)



PARAMETERS :




DESCRIPTION :

isnan(x) returns a boolean vector or matrix which contains true entries corresponding with "Not a Number" x entries and false entries corresponding with regular x entries.


EXAMPLE :

isnan([1 0.01 -%nan %inf-%inf])



See Also : isinf X



3.70   isreal check if a variable as real or complex entries




CALLING SEQUENCE :

t=isreal(x)
t=isreal(x,eps)



PARAMETERS :




DESCRIPTION :

isreal(x) returns true if x is stored as a real variable and false if x stores complex numbers.

isreal(x,eps)
returns true if x is stored as a real variable or if maximum absolute value of imaginary floating points if less or equal than eps.


EXAMPLE :

isreal([1 2])
isreal(1+0*%i)
isreal(1+0*%i,0)
isreal(1+%s)
isreal(sprand(3,3,0.1))

3.71   kron Kronecker product (.*.)




CALLING SEQUENCE :

kron(x,y) 
x.*.y



DESCRIPTION :

Kronecker tensor product of two matrices x and y. Same as x.*.y


EXAMPLE :

A=[1,2;3,4];
kron(A,A)
A.*.A
A(1,1)=%i;
kron(A,A)

3.72   ldivf left symbolic division




CALLING SEQUENCE :

ldivf('d','c') 



DESCRIPTION :

returns the string 'c\d' Trivial simplifications such as '1\c' = 'c' are performed.


EXAMPLE :

ldivf('1','1')
ldivf('a','0')
ldivf('a','x')
ldivf('2','4')



See Also : rdivf X, addf X, mulf X, evstr X



3.73   linspace linearly spaced vector




CALLING SEQUENCE :

[v]=linspace(x1,x2 [,n])



PARAMETERS :




DESCRIPTION :

Linearly spaced vector. linspace(x1, x2) generates a row vector of n (default value=100) linearly equally spaced points between x1 and x2.


EXAMPLE :

linspace(1,2,10)



See Also : logspace X



3.74   log natural logarithm




CALLING SEQUENCE :

y=log(x)



PARAMETERS :




DESCRIPTION :

log(x) is the "element-wise" logarithm. y(i,j)=log(x(i,j)). For matrix logarithm see logm.


EXAMPLE :

exp(log([1,%i,-1,-%i]))



See Also : exp X, logm X, ieee X



3.75   log10 logarithm




CALLING SEQUENCE :

y=log10(x)



PARAMETERS :




DESCRIPTION :

decimal logarithm.If x is a vector log10(x)=[log10(x1),...,log10(xn)].


EXAMPLE :

10.^log10([1,%i,-1,-%i])



See Also : log X, hat X, ieee X



3.76   logm square matrix logarithm




CALLING SEQUENCE :

y=logm(x)



PARAMETERS :




DESCRIPTION :

logm(x) is the matrix logarithm of x. The result is complex if x is not positive or definite positive. If x is a symmetric matrix, then calculation is made by schur form. Otherwise, x is assumed diagonalizable. One has expm(logm(x))=x


EXAMPLE :

A=[1,2;3,4];
logm(A)
expm(logm(A))
A1=A*A';
logm(A1)
expm(logm(A1))
A1(1,1)=%i;
expm(logm(A1))



See Also : expm X, log X



3.77   logspace logarithmically spaced vector




CALLING SEQUENCE :

logspace(d1,d2, [n]) 



PARAMETERS :




DESCRIPTION :

returns a row vector of n logarithmically equally spaced points between 10^d1 and 10^d2. If d2=%pi then the points are between 10^d1 and pi.


EXAMPLE :

logspace(1,2,10)



See Also : linspace X



3.78   macr2lst function to list conversion




CALLING SEQUENCE :

[txt]=macr2lst(function-name)



DESCRIPTION :

This primitive converts a compiled Scilab function function-name into a list which codes the internal representation of the function. For use with mac2for.


See Also : macrovar X



3.79   macrovar variables of function




CALLING SEQUENCE :

vars=macrovar(function)



PARAMETERS :




DESCRIPTION :

Returns in a list the set of variables used by a function. vars is a list made of five column vectors of character strings

in
: input variables (vars(1))

out
: output variables (vars(2))

globals
: global variables (vars(3))

called
: names of functions called (vars(4))

locals
: local variables (vars(5))


EXAMPLE :

deff('y=f(x1,x2)','loc=1;y=a*x1+x2-loc')
vars=macrovar(f)



See Also : string X, macr2lst X



3.80   manedit editing a manual item




CALLING SEQUENCE :

manedit(manitem ,[editor])



PARAMETERS :




DESCRIPTION :

edit(manitem ,[editor]) opens the file manitem in the editor given by editor.

Default editor is Emacs. This function should be customized according to your needs.


EXAMPLE :

//manedit('lqg')



See Also : whereis X, edit X



3.81   mean mean (row mean, column mean) of vector/matrix entries




CALLING SEQUENCE :

y=mean(x)
y=mean(x,'r')
y=mean(x,'c')



PARAMETERS :




DESCRIPTION :

For a vector or a matrix x, y=mean(x) returns in the scalar y the mean of all the entries of x.

y=mean(x,'r')
(or, equivalently, y=mean(x,2)) is the rowwise mean. It returns in each entry of the column vector y the mean of each row of x.

y=mean(x,'c')
(or, equivalently, y=mean(x,1)) is the columnwise mean. It returns in each entry of the row vector y the mean of each column of x.


EXAMPLE :

A=[1,2,10;7,7.1,7.01];
mean(A)
mean(A,'r')
mean(A,'c')



See Also : sum X, median X,st_deviation X



3.82   median median (row median, column median) of vector/matrix entries




CALLING SEQUENCE :

y=median(x)
y=median(x,'r')
y=median(x,'c')



PARAMETERS :




DESCRIPTION :

For a vector or a matrix x, y=median(x) returns in the scalar y the median of all the entries of x.

y=median(x,'r')
(or, equivalently, y=median(x,2)) is the rowwise median. It returns in each entry of the column vector y the median of each row of x.

y=median(x,'c')
(or, equivalently, y=median(x,1)) is the columnwise median. It returns in each entry of the row vector y the median of each column of x.


EXAMPLE :

A=[1,2,10;7,7.1,7.01];
median(A)
median(A,'r')
median(A,'c')



See Also : sum X, mean X



3.83   modulo arithmetic remainder modulo m




CALLING SEQUENCE :

i=modulo(n,m)



PARAMETERS :

n,m: integers


DESCRIPTION :

computes i= n (modulo m) i.e. remainder of n divided by m (n and m integers).

i= n - m .* int (n ./ m)


EXAMPLE :

n=[1,2,10,15];m=[2,2,3,5];
modulo(n,m)

3.84   mulf symbolic multiplication




CALLING SEQUENCE :

mulf('d','c')



DESCRIPTION :

returns the string 'c*d' Trivial simplifications such as '1*c' = 'c' are performed.


EXAMPLE :

mulf('1','a')
mulf('0','a')
'a'+'b'   //Caution...



See Also : rdivf X, addf X, subf X



3.85   nnz number of non zero entries in a matrix




CALLING SEQUENCE :

n=nnz(X)



PARAMETERS :




DESCRIPTION :

nnz counts the number of non zero entries in a sparse or full matrix


EXAMPLE :

sp=sparse([1,2;4,5;3,10],[1,2,3]);
nnz(sp)
a=[1 0 0 0 2];
nnz(a)



See Also : spget X





3.86   norm matrix norms




CALLING SEQUENCE :

[y]=norm(x [,flag])



PARAMETERS :




DESCRIPTION :

For matrices

1


EXAMPLE :

A=[1,2,3];
norm(A,1)
norm(A,'inf')
A=[1,2;3,4]
max(svd(A))-norm(A)

A=sparse([1 0 0 33 -1])
norm(A)




See Also : h_norm X, dhnorm X, h2norm X, abs X



3.87   pen2ea pencil to E,A conversion




CALLING SEQUENCE :

[E,A]=pen2ea(Fs)



PARAMETERS :




DESCRIPTION :

Utility function. Given the pencil Fs=s*E-A, returns the matrices E and A.


EXAMPLE :

E=[1,0];A=[1,2];s=poly(0,'s');
[E,A]=pen2ea(s*E-A)

3.88   pertrans pertranspose




CALLING SEQUENCE :

[Y]=pertrans(X)



PARAMETERS :




DESCRIPTION :

Y=pertrans(X) returns the pertranspose of X, i.e. the symmetric of X w.r.t the second diagonal (utility function).


EXAMPLE :

A=[1,2;3,4]
pertrans(A)

3.89   prod product




CALLING SEQUENCE :

y=prod(x)
y=prod(x,'r') or y=prod(x,1)
y=prod(x,'c') or y=prod(x,2)



PARAMETERS :




DESCRIPTION :

For a vector or a matrix x, y=prod(x) returns in the scalar y the prod of all the entries of x, , e.g. prod(1:n) is n!

y=prod(x,'r')
(or, equivalently, y=prod(x,1))computes the rows elementwise product of x. y is the row vector: y(i)=prod(x(i,:)).

y=prod(x,'c')
(or, equivalently, y=prod(x,2)) computes the columns elementwise product of x. y is the column vector: y(i)=prod(x(:,i)).

prod
is not implemented for sparse matrices.


EXAMPLE :

A=[1,2;0,100];
prod(A)
prod(A,'c')
prod(A,'r')



See Also : sum X, cumprod X



3.90   rdivf right symbolic division




CALLING SEQUENCE :

["r"]=ldivf("d","c") 



PARAMETERS :




DESCRIPTION :

returns the string "c/d" Trivial simplifications such as "c/1" = "c" are performed.


EXAMPLE :

ldivf('c','d')
ldivf('1','2')
ldivf('a','0')



See Also : ldivf X



3.91   readc_ read a character string




CALLING SEQUENCE :

[c]=readc_(unit)
[c]=readc_()



DESCRIPTION :

readc_ reads a character string. This function allows one to interrupt an exec file without pause; the exec file stops until carriage return is made.


See Also : read X



3.92   readmps reads a file in MPS format




CALLING SEQUENCE :

[m,n,nza,irobj,namec,nameb,namran,nambnd,name,stavar,rwstat,hdrwcd,lnkrw,hdclcd,lnkcl,rwnmbs,clpnts,acoeff,rhs,ranges,ubounds,lbounds] =readmps ('file-name',maxm,maxn,maxnza,big,dlobnd,dupbnd);        



PARAMETERS :




DESCRIPTION :

[m,n,nza,irobj,namec.nameb,namran,nambnd,name,stavar,rwstat,hdrwcd,lnkrw,hdclcd,rwnmbs,clpnts,acoeff,rhs,ranges,ubounds,lbounds] = readmps ('file-name',maxm,maxn,maxnza,big,dlobnd,dupbnd). Utility function: reads file 'file-name.mps' in mps format. It is an interface with the program rdmps1.f of hopdm (J. Gondzio). For a description of the variables, see the file rdmps1.f.


EXAMPLE :

//File : test.mps (uncomment)
//NAME          TESTPROB
//ROWS
// N  COST
// L  LIM1
// G  LIM2
// E  MYEQN
//COLUMNS
//    XONE      COST                 1   LIM1                 1
//    XONE      LIM2                 1
//    YTWO      COST                 4   LIM1                 1
//    YTWO      MYEQN               -1
//    ZTHREE    COST                 9   LIM2                 1
//    ZTHREE    MYEQN                1
//RHS
//    RHS1      LIM1                 5   LIM2                10
//    RHS1      MYEQN                7
//BOUNDS
// UP BND1      XONE                 4
// LO BND1      YTWO                -1
// UP BND1      YTWO                 1
//ENDATA

//// objective:
//   min     XONE + 4 YTWO + 9 ZTHREE
//// constraints:
//  LIM1:    XONE +   YTWO            < = 5
//  LIM2:    XONE +            ZTHREE > = 10
// MYEQN:         -   YTWO  +  ZTHREE   = 7
//// Bounds
//  0 < = XONE < = 4
// -1 < = YTWO < = 1
//// End
maxm = 5;
maxn = 4;
maxnza = 9;
big = 10^30;
dlobnd = 0;
dupbnd = 10^30;        
//        
//[m,n,nza,irobj,namec,nameb,namran,nambnd,name,stavar,rwstat,hdrwcd,...
//lnkrw,hdclcd,lnkcl,rwnmbs,clpnts,acoeff,rhs,ranges,ubounds,lbounds] = ...
//readmps ('test',maxm,maxn,maxnza,big,dlobnd,dupbnd);

3.93   sci2exp converts variable to expression




CALLING SEQUENCE :

t=sci2exp(a [,nam] [,lmax])



PARAMETERS :




DESCRIPTION  :

sci2exp converts variable to an instruction if nam is given or to an expression .


EXAMPLE :

  a=[1 2;3 4]
  sci2exp(a,'aa')
  sci2exp(a,'aa',0)
  sci2exp(ssrand(2,2,2))
  sci2exp(poly([1 0 3 4],'s'),'fi')

3.94   sci2map Scilab to Maple variable conversion




CALLING SEQUENCE :

txt=sci2map(a,Map-name) 



PARAMETERS :




DESCRIPTION :

Makes Maple code necessary to send the Scilab variable a to Maple : the name of the variable in Maple is Map-name. A Maple procedure maple2scilab can be found in SCIDIR/maple directory.


EXAMPLE :

txt=[sci2map([1 2;3 4],'a');
     sci2map(%s^2+3*%s+4,'p')]

3.95   setmenu interactive button or menu activation




CALLING SEQUENCE :

setmenu(button [,nsub]) 
setmenu(gwin,button [,nsub])



PARAMETERS :




DESCRIPTION :

The function allows the user to make active buttons or menus created by addmenu in the main or graphics windows command panels.


EXAMPLE :

addmenu('foo')   //New button made in main scilab window
unsetmenu('foo')   //button foo cannot be activated (grey string)
setmenu('foo')     //button foo can be activated (black string)



See Also : delmenu X, unsetmenu X, addmenu X



3.96   sin sine function




CALLING SEQUENCE :

[t]=sin(x)



PARAMETERS :




DESCRIPTION :

For a vector or a matrix, sin(x) is the sine of its elements . For matrix sine use sinm(X) function.


EXAMPLE :

asin(sin([1,0,%i]))



See Also : sinm X



3.97   sinh hyperbolic sine




CALLING SEQUENCE :

[t]=sinh(x) 



PARAMETERS :




DESCRIPTION :

the elements of vector t are the hyperbolic sine of elements of vector x.


EXAMPLE :

asinh(sinh([0,1,%i]))



See Also : asinh X



3.98   sinhm matrix hyperbolic sine




CALLING SEQUENCE :

t=sinhm(x)



PARAMETERS :




DESCRIPTION :

sinhm is the matrix hyperbolic sine of the matrix x. t=(expm(x)-expm(-x))/2


EXAMPLE :

A=[1,2;2,3]
asinhm(sinhm(A))
A(1,1)=%i;sinhm(A)-(expm(A)-expm(-A))/2   //Complex case



See Also : sinh X



3.99   sinm matrix sine function




CALLING SEQUENCE :

t=sinm(x)



PARAMETERS :




DESCRIPTION :

sinm(x) is matrix sine of x matrix.


EXAMPLE :

A=[1,2;2,4];
sinm(A)+0.5*%i*(expm(%i*A)-expm(-%i*A))



See Also : sin X, asinm X



3.100   smooth smoothing by spline functions




CALLING SEQUENCE :

[pt]=smooth(ptd [,step])



PARAMETERS :




DESCRIPTION :

this function computes interpolation by spline functions for a given set of points in the plane. The coordinates are (ptd(1,i),ptd(2,i)). The components ptd(1,:) must be in ascending order. The default value for the step is abs(maxi(ptd(1,:))-mini(ptd(1,:)))/100


EXAMPLE :

x=[1 10 20 30 40];
y=[1 30 -10 20 40];
plot2d(x',y',[3],"011"," ",[-10,-40,50,50]);
yi=smooth([x;y],0.1);
plot2d(yi(1,:)',yi(2,:)',[1],"000");



See Also : splin X, interp X, interpln X



3.101   solve symbolic linear system solver




CALLING SEQUENCE :

[x]=solve(A,b)



PARAMETERS :




DESCRIPTION :

solves A*x = b when A is an upper triangular matrix made of character strings.


EXAMPLE :

A=['1','a';'0','2'];   //Upper triangular 
b=['x';'y'];
w=solve(A,b)
a=1;x=2;y=5;
evstr(w)
inv([1,1;0,2])*[2;5]



See Also : trianfml X



3.102   sort decreasing order sorting




CALLING SEQUENCE :

[s, [k]]=sort(v)
[s, [k]]=sort(v,'r')
[s, [k]]=sort(v,'c')



PARAMETERS :




DESCRIPTION :

s=sort(v) sorts v in decreasing order. If v is a matrix, sorting is done columnwise, v being seen as the stacked vector v(:). [s,k]=sort(v) gives in addition the indices of entries of s in v, i.e. v(k(:)) is the vector s.

s=sort(v,'r')
sorts the rows of v in decreasing order i.e. each column of s is obtained from each column of v by reordering it in decreasing order. [s,k]=sort(v,'r') returns in addition in each column of k the indices such that v(k(:,i),i)=s(:,i) for each column index i.

s=sort(v,'c')
sorts the columns of v in decreasing order i.e. each row of s is obtained from each row of v by reordering it in decreasing order. [s,k]=sort(v,'c') returns in addition in each row of k the indices such that v(i,k(i,:))=s(i,:) for each row index i.

Complex matrices or vectors are sorted w.r.t their magnitude.

y=sort(A)
is valid when A is a sparse vector. Column/row sorting is not implemented for sparse matrices.


EXAMPLE :

[s,p]=sort(rand(1,10));
//p  is a random permutation of 1:10
A=[1,2,5;3,4,2];
[Asorted,q]=sort(A);A(q(:))-Asorted(:)
v=1:10;
sort(v)
sort(v')
sort(v,'r')  //Does nothing for row vectors
sort(v,'c')



See Also : find X



3.103   sp2adj converts sparse matrix into adjacency form




CALLING SEQUENCE :

[xadj,adjncy,anz]= sp2adj(A)


PARAMETERS :

.TP 7
A  
:  real or complex sparse matrix (nz non-zero entries)
.TP 7
xadj  
:  integer vector of length (n+1).
.TP 7
adjncy
:  integer vector of length nz containing the row indices 
   for the corresponding elements in anz
.TP 7
anz  
:  column vector of length nz, containing the non-zero 
   elements of A



DESCRIPTION :

\fVsp2adj\fR converts a sparse matrix into its adjacency form (utility
fonction).
\fVA =  n x m\fR sparse matrix. \fVxadj, adjncy, anz\fR = adjacency 
representation of \fVA\fR i.e:
.LP
\fVxadj(j+1)-xadj(j)\fR = number of non zero entries in row j.
\fVadjncy\fR = column index of the non zeros entries 
in row 1, row 2,..., row n.
\fVanz\fR = values of non zero entries in row 1, row 2,..., row n.
\fVxadj\fR is a (column) vector of size n+1 and 
\fVadjncy\fR is an integer (column) vector of size \fVnz=nnz(A)\fR.
\fVanz\fR is a real vector of size \fVnz=nnz(A)\fR.



EXAMPLE :

A = sprand(100,50,.05);
[xadj,adjncy,anz]= sp2adj(A);
[n,m]=size(A);
p = adj2sp(xadj,adjncy,anz,[n,m]);
A-p,



See Also : adj2sp X, sparse X, spcompack X, spget X



3.104   sparse sparse matrix definition




CALLING SEQUENCE :

sp=sparse(X)
sp=sparse(ij,v [,mn])



PARAMETERS :




DESCRIPTION :

sparse is used to build a sparse matrix. Only non-zero entries are stored.

sp = sparse(X)
converts a full matrix to sparse form by squeezing out any zero elements. (If X is already sparse sp is X).

sp=sparse(ij,v [,mn])
builds an mn(1)-by-mn(2) sparse matrix with sp(ij(k,1),ij(k,2))=v(k). ij and v must have the same column dimension. If optional mn parameter is not given the sp matrix dimensions are the max value of ij(:,1) and ij(:,2) respectively.

Operations (concatenation, addition, etc,) with sparse matrices are made using the same syntax as for full matrices.

Elementary functions are also available (abs,maxi,sum,diag,...
) for sparse matrices.

Mixed operations (full-sparse) are allowed. Results are full or sparse depending on the operations.


EXAMPLE :

sp=sparse([1,2;4,5;3,10],[1,2,3])
size(sp)
x=rand(2,2);abs(x)-full(abs(sparse(x)))



See Also : full X, spget X, sprand X, speye X, lufact X





3.105   spcompack converts a compressed adjacency representation




CALLING SEQUENCE :

adjncy = spcompak(xadj,xlindx,lindx)


PARAMETERS :

.TP 7
xadj  
:  integer vector of length (n+1).
.TP 7
xlindx
:  integer vector of length n+1 (pointers).
.TP 7
lindx
:  integer vector
.TP 7
adjncy
:  integer vector



DESCRIPTION :

Utility fonction \fVspcompak\fR is used to convert a compressed adjacency
representation into standard adjacency representation.



EXAMPLE :

// A is the sparse matrix:
A=[1,0,0,0,0,0,0;
   0,1,0,0,0,0,0;
   0,0,1,0,0,0,0;
   0,0,1,1,0,0,0;
   0,0,1,1,1,0,0;
   0,0,1,1,0,1,0;
   0,0,1,1,0,1,1];
A=sparse(A);
//For this matrix, the standard adjacency representation is given by:
xadj=[1,2,3,8,12,13,15,16];
adjncy=[1, 2, 3,4,5,6,7, 4,5,6,7, 5, 6,7, 7];
//(see sp2adj).
// increments in vector xadj give the number of non zero entries in each column
// ie there is 2-1=1 entry in the column 1
//    there is 3-2=1 entry in the column 2
//    there are 8-3=5 entries in the column 3
//              12-8=4                      4
//etc
//The row index of these entries is given by the adjncy vector
// for instance, 
// adjncy (3:7)=adjncy(xadj(3):xadj(4)-1)=[3,4,5,6,7] 
// says that the 5=xadj(4)-xadj(3) entries in column 3 have row
// indices 3,4,5,6,7.
//In the compact representation, the repeated sequences in adjncy
//are eliminated.
//Here in adjncy the sequences 4,5,6,7  and 7 are eliminated.
//The standard structure (xadj,adjncy) takes the compressed form (lindx,xlindx)
lindx=[1, 2, 3,4,5,6,7, 5, 6,7];
xlindx=[1,2,3,8,9,11];
//(Columns 4 and 7 of A are eliminated).
//A can be reconstructed from (xadj,xlindx,lindx).
[xadj,adjncy,anz]= sp2adj(A);
adjncy -  spcompack(xadj,xlindx,lindx)



See Also : sp2adj X, adj2sp X, spget X



3.106   speye sparse identity matrix




CALING SEQUENCE :

Isp=speye(nrows,ncols)
Isp=speye(A)



PARAMETERS :




DESCRIPTION :

Isp=speye(nrows,ncols) returns a sparse identity matrix Isp with nrows rows, ncols columns. (Non square identity matrix have a maximal number of ones along the main diagonal).

Isp=speye(A)
returns a sparse identity matrix with same dimensions as A. If [m,n]=size(A), speye(m,n) and speye(A) are equivalent. In particular speye(3) is not equivalent to speye(3,3).


EXAMPLE :

eye(3,3)-full(speye(3,3))



See Also : sparse X, full X, eye X, spzeros X, spones X





3.107   spget retrieves entries of sparse matrix




CALLING SEQUENCE :

[ij,v,mn]=spget(sp)



PARAMETERS :




DESCRIPTION :

spget is used to convert the internal representation of sparse matrices into the standard ij, v representation.

Non zero entries of sp
are located in rows and columns with indices in ij.


EXAMPLE :

sp=sparse([1,2;4,5;3,10],[1,2,3])
[ij,v,mn]=spget(sp);



See Also : sparse X, sprand X, speye X, lufact X





3.108   splin spline function




CALLING SEQUENCE :

d=splin(x,f [,"periodic"])



PARAMETERS :




DESCRIPTION :

Given values fi of a function f at given points xi (fi=f(xi)) this primitive computes a third order spline function S which interpolates the function f. The components of x must be in increasing order. For a periodic spline f(1) must equal f(n); S is defined through the triple (x,f,d) where d=spline(x,f) is the vector of the estimated derivatives of S at xi (fi=S(xi),di=S'(xi)). This function should be used in conjunction with interp.


EXAMPLE :

x=0:0.5:10;f=sin(x);
d=splin(x,f);
S=interp(0:0.1:10,x,f,d);
plot2d(x',f',-1);
plot2d((0:0.1:10)',S',2,'000')



See Also : interp X, smooth X



3.109   spones sparse matrix




SYNTAX :

sp=spones(A)


PARAMETERS :




DESCRIPTION :

sp=spones(A) generates a matrix with the same sparsity structure as A, but with ones in the nonzero positions;


EXAMPLE :

A=sprand(10,12,0.1);
sp=spones(A)
B = A~=0
bool2s(B)



See Also : sparse X, full X, eye X, speye X, spzeros X





3.110   sprand sparse random matrix




CALING SEQUENCE :

sp=sprand(nrows,ncols,fill [,typ])



PARAMETERS :




DESCRIPTION :

sp=sprand(nrows,ncols,fill) returns a sparse matrix sp with nrows rows, ncols columns and approximately fill*nrows*ncols non-zero entries.

If typ='uniform'
uniformly distributed values are generated. If typ='normal' normally distributed values are generated.


EXAMPLE :

W=sprand(100,1000,0.001);



See Also : sparse X, full X, rand X, speye X





3.111   spzeros sparse zero matrix




SYNTAX :

sp=spzeros(nrows,ncols)

sp=spzeros(A)


PARAMETERS :




DESCRIPTION :

sp=spzeros(nrows,ncols,fill) returns a sparse zero matrix sp with nrows rows, ncols columns. (Equivalent to sparse([],[],[nrow,ncols]))

sp=spzeros(A)
returns a sparse zero matrix with same dimensions as A. If [m,n]=size(A), spzeros(m,n) and spzeros(A) are equivalent. In particular spzeros(3) is not equivalent to spzeros(3,3).


EXAMPLE :

sum(spzeros(1000,1000))



See Also : sparse X, full X, eye X, speye X, spones X





3.112   sqrt square root




CALLING SEQUENCE :

y=sqrt(x)



PARAMETERS :




DESCRIPTION :

sqrt(x) is the vector of the square root of the x elements. Result is complex if x is negative.


EXAMPLE :

sqrt([2,4])
sqrt(-1)



See Also : hat X, sqrtm X



3.113   sqrtm matrix square root




CALLING SEQUENCE :

y=sqrtm(x)



PARAMETERS :




DESCRIPTION :

y=sqrt(x) is the matrix square root of the x x matrix (x=y^2) Result may not be accurate if x is not symmetric.


EXAMPLE :

x=[0 1;2 4]
w=sqrtm(x); 
norm(w*w-x)
x(1,2)=%i;
w=sqrtm(x);norm(w*w-x,1)



See Also : expm X, sqroot X



3.114   ssprint pretty print for linear system




CALLING SEQUENCE :

ssprint(sl [,out])



PARAMETERS :




DESCRIPTION :

pretty print of a linear system in state-space form sl=(A,B,C,D) syslin list.


EXAMPLE :

 a=[1 1;0 1];b=[0 1;1 0];c=[1,1];d=[3,2];
 ssprint(syslin('c',a,b,c,d))
 ssprint(syslin('d',a,b,c,d))



See Also : texprint X



3.115   ssrand random system generator




CALLING SEQUENCE :

sl=ssrand(nout,nin,nstate)
[sl,U]=ssrand(nout,nin,nstate,flag)



PARAMETERS :




DESCRIPTION :

sl=ssrand(nout,nin,nstate) returns a random strictly proper (D=0) state-space system of size [nout,nint] represented by a syslin list and with nstate state variables.

[sl,U]=ssrand(nout,nin,nstate,flag)
returns a test linear system with given properties specified by flag. flag can be one of the following:
flag=list('co',dim_cont_subs)  
flag=list('uo',dim_unobs_subs)
flag=list('ncno',dim_cno,dim_ncno,dim_co,dim_nco)
flag=list('st',dim_cont_subs,dim_stab_subs,dim_stab0)  
flag=list('dt',dim_inst_unob,dim_instb0,dim_unobs)
flag=list('on',nr,ng,ng0,nv,rk)
flag=list('ui',nw,nwu,nwui,nwuis,rk)
The complete description of the Sys is given in the code of the ssrand function (in SCIDIR/macros/util). For example with flag=list('co',dim_cont_subs) a non-controllable system is return and dim_cont_subs is the dimension of the controllable subspace of Sys. The character strings 'co','uo','ncno','st','dt','on','ui' stand for "controllable", "unobservable", "non-controllable-non-observable", "stabilizable","detectable","output-nulling","unknown-input".


EXAMPLE :

//flag=list('st',dim_cont_subs,dim_stab_subs,dim_stab0)  
//dim_cont_subs<=dim_stab_subs<=dim_stab0  
//pair (A,B) U-similar to:
//    [*,*,*,*;     [*;    
//    [0,s,*,*;     [0;
//A=  [0,0,i,*;   B=[0;
//    [0,0,0,u]     [0]
//     
// (A11,B1) controllable  s=stable matrix i=neutral matrix u=unstable matrix
[Sl,U]=ssrand(2,3,8,list('st',2,5,5));
w=ss2ss(Sl,inv(U)); //undo the random change of basis => form as above
[n,nc,u,sl]=st_ility(Sl);n,nc



See Also : syslin X



3.116   st_deviation standard deviation (row or column-wise) of vector/matrix entries




CALLING SEQUENCE :

y=st_deviation(x)
y=st_deviation(x,'r')
y=st_deviation(x,'c')



PARAMETERS :




DESCRIPTION :

st_deviation computes the "sample" standard deviation, that is, it is normalized by N-1, where N is the sequence length.

For a vector or a matrix x
, y=st_deviation(x) returns in the scalar y the standard deviation of all the entries of x.

y=st_deviation(x,'r')
(or, equivalently, y=st_deviation(x,2)) is the rowwise standard deviation. It returns in each entry of the column vector y the standard deviation of each row of x.

y=st_deviation(x,'c')
(or, equivalently, y=st_deviation(x,1)) is the columnwise st_deviation. It returns in each entry of the row vector y the standard deviation of each column of x.


EXAMPLE :

A=[1,2,10;7,7.1,7.01];
st_deviation(A)
st_deviation(A,'r')
st_deviation(A,'c')



See Also : sum X, median X, mean X



3.117   strcat catenate character strings




CALLING SEQUENCE :

[txt]=strcat(vstr [,strp])



PARAMETERS :




DESCRIPTION :

catenates character strings : txt=strs(1)+...+strs(n)

txt=strcat(strs,opt) returns txt=strs(1)+opt+...+opt+strs(n). The plus symbol does the same: "a"+"b" is the same as strcat(["a","b"])


EXAMPLE :

strcat(string(1:10),',')



See Also : string X, strings X



3.118   strindex search position of a character string in an other string.




CALLING SEQUENCE :

ind=strindex(str1,str2)



PARAMETERS :




DESCRIPTION :

strindex searches indexes where str2(i) is found in str1 for each k it exist a ishuch that part(str1,ind(k)+(0:length(str2(i))-1)) is the same string than str2(i)

When str2 is a vector and str2


EXAMPLE :

k=strindex('SCI/demos/scicos','/')
k=strindex('SCI/demos/scicos','SCI/')
k=strindex('SCI/demos/scicos','!')
k=strindex('aaaaa','aa') 
k=strindex('SCI/demos/scicos',['SCI','sci'])



See Also : string X, strings X



3.119   stripblanks strips leading and trailing blanks of strings




CALLING SEQUENCE :

txt=stripblanks(txt)



PARAMETERS :




DESCRIPTION :

stripblanks strips leading and trailing blanks of strings


EXAMPLE :

a='  123   ';
'!'+a+'!'
'!'+stripblanks(a)+'!'
a=['  123   ',' xyz']
strcat(stripblanks(a))

3.120   strsubst substitute a character string by another in a character string.




CALLING SEQUENCE :

str=strsubst(str1,str2,str3)



PARAMETERS :




DESCRIPTION :

strsubst replaces all occurrences of str2 in str1 by str3.


EXAMPLE :

strsubst('SCI/demos/scicos','SCI','.')
strsubst('SCI/demos/scicos','/',' ')



See Also : string X, strings X



3.121   subf symbolic subtraction




CALLING SEQUENCE :

["c"]=subf("a","b")



PARAMETERS :




DESCRIPTION :

returns the character string c="a-b" Trivial simplifications such as subf("0","a") or subf("1","2") are performed.


EXAMPLE :

subf('0','a')
subf('2','1')
subf('a','0')



See Also : mulf X, ldivf X, rdivf X, eval X, evstr X



3.122   sum sum (row sum, column sum) of vector/matrix entries




CALLING SEQUENCE :

y=sum(x)
y=sum(x,'r') or y=sum(x,1)

y=sum(x,'c') or y=sum(x,2)



PARAMETERS :




DESCRIPTION :

For a vector or a matrix x, y=sum(x) returns in the scalar y the sum of all the entries of x.

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

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


EXAMPLE :

A=[1,2;3,4];
trace(A)-sum(diag(A))
sum(A,'c')-A*ones(2,1)
sum(A+%i)
A=sparse(A);sum(A,'c')-A*ones(2,1)
s=poly(0,'s');
M=[s,%i+s;s^2,1];
sum(M),sum(M,2)



See Also : cumsum X, prod X



3.123   sysconv system conversion




CALLING SEQUENCE :

[s1,s2]=sysconv(s1,s2)



PARAMETERS :

s1,s2 : list (linear syslin systems)


DESCRIPTION :

Converts s1 and s2 into common representation in order that system interconnexion operations can be applied. Utility function for experts. The conversion rules in given in the following table.


EXAMPLE :

s1=ssrand(1,1,2);
s2=ss2tf(s1);
[s1,s2]=sysconv(s1,s2);



See Also : syslin X, ss2tf X, tf2ss X



3.124   sysdiag block diagonal system connection




CALLING SEQUENCE :

r=sysdiag(a1,a2,...,an)



DESCRIPTION :

Returns the block-diagonal system made with subsystems put in the main diagonal Used in particular for system interconnections.


REMARK  :

At most 17 arguments.


EXAMPLES :

 s=poly(0,'s')
 sysdiag(rand(2,2),1/(s+1),[1/(s-1);1/((s-2)*(s-3))])
 sysdiag(tf2ss(1/s),1/(s+1),[1/(s-1);1/((s-2)*(s-3))])

 s=poly(0,'s')
 sysdiag(rand(2,2),1/(s+1),[1/(s-1);1/((s-2)*(s-3))])
 sysdiag(tf2ss(1/s),1/(s+1),[1/(s-1);1/((s-2)*(s-3))])



See Also : brackets X, insertion X, feedback X



3.125   syslin linear system definition




CALLING SEQUENCE :

[sl]=syslin(dom,A,B,C [,D [,x0] ])
[sl]=syslin(dom,N,D)
[sl]=syslin(dom,H)



PARAMETERS :




DESCRIPTION :

syslin defines a linear system as a list and checks consistency of data.

dom
specifies the time domain of the system and can have the following values:

dom='c'
for a continuous time system, dom='d' for a discrete time system, n for a sampled system with sampling period n (in seconds).

dom=[]
if the time domain is undefined

State-space representation:
sl=syslin(dom,A,B,C [,D [,x0] ])
represents the system :
      s x  = A*x + B*u
        y  = C*x + D*u
      x(0) = x0
The output of syslin is a list of the following form: sl=tlist(['lss','A','B','C','D','X0','dt'],A,B,C,D,x0,dom) Note that D is allowed to be a polynomial matrix (improper systems).

Transfer matrix representation:
sl=syslin(dom,N,D) 
sl=syslin(dom,H)
The output of syslin is a list of the following form : sl=tlist(['r','num','den','dt'],N,D,dom) or sl=tlist(['r','num','den','dt'],H(2),H(3),dom).

Linear systems defined as syslin
can be manipulated as usual matrices (concatenation, extraction, transpose, multiplication, etc) both in state-space or transfer representation.

Most of state-space control functions receive a syslin
list as input instead of the four matrices defining the system.


EXAMPLES :

A=[0,1;0,0];B=[1;1];C=[1,1];
S1=syslin('c',A,B,C)   //Linear system definition
S1("A")    //Display of A-matrix
S1("X0"), S1("dt") // Display of X0 and time domain
s=poly(0,'s');
D=s;
S2=syslin('c',A,B,C,D)
H1=(1+2*s)/s^2, S1bis=syslin('c',H1)
H2=(1+2*s+s^3)/s^2, S2bis=syslin('c',H2)
S1+S2
[S1,S2]
ss2tf(S1)-S1bis
S1bis+S2bis
S1*S2bis
size(S1)



See Also : tlist X, lsslist X, rlist X, ssrand X, ss2tf X, tf2ss X, dscr X, abcd X



3.126   tan tangent




CALLING SEQUENCE :

[t]=tan(x)   



PARAMETERS :




DESCRIPTION :

The elements of t are the tangent of the elements of x.


EXAMPLE :

x=[1,%i,-1,-%i]
tan(x)
sin(x)./cos(x)



See Also : atan X, tanm X



3.127   tanh hyperbolic tangent




CALLING SEQUENCE :

t=tanh(x) 



DESCRIPTION :

the elements of t are the hyperbolic tangents of the elements of x


EXAMPLE :

x=[1,%i,-1,-%i]
tanh(x)
sinh(x)./cosh(x)



See Also : atanh X, tan X, tanhm X



3.128   tanhm matrix hyperbolic tangent




CALLING SEQUENCE :

t=tanhm(x) 



PARAMETERS :




DESCRIPTION :

tanhm is the matrix hyperbolic tangent of the matrix x.


See Also : tanh X



3.129   tanm matrix tangent




CALLING SEQUENCE :

[t]=tanm(x)   



PARAMETERS :




DESCRIPTION :

tanm(x) is the matrix tangent of the square matrix x


EXAMPLE :

A=[1,2;3,4];
tanm(A)



See Also : tan X, expm X, sinm X, atanm X



3.130   timer cpu time




CALLING SEQUENCE :

timer() 



DESCRIPTION :

Returns the CPU time from the preceding call to timer().


EXAMPLE :

timer();A=rand(100,100);timer()



See Also : unix_g X



3.131   toeplitz toeplitz matrix




CALING SEQUENCE :

A=toeplitz(c [,r]) 



PARAMETERS :




DESCRIPTION :

returns the Toeplitz matrix whose first row is r and first column is c. c(1) must be equal to r(1). toeplitz(c) returns the symmetric Toeplitz matrix.


EXAMPLE :

A=toeplitz(1:5);
//
T=toeplitz(1:5,1:2:7);T1=[1 3 5 7;2 1 3 5;3 2 1 3;4 3 2 1;5 4 3 2];
T-T1
//
s=poly(0,'s');
t=toeplitz([s,s+1,s^2,1-s]);
t1=[s,1+s,s*s,1-s;1+s,s,1+s,s*s;s*s,1+s,s,1+s;1-s,s*s,1+s,s]
t-t1
//
t=toeplitz(['1','2','3','4']);
t1=['1','2','3','4';'2','1','2','3';'3','2','1','2';'4','3','2','1']



See Also : matrix X



3.132   trfmod poles and zeros display




CALLING SEQUENCE :

[hm]=trfmod(h [,job])



DESCRIPTION :

To visualize the pole-zero structure of a SISO transfer function h . Interactive simplification of h. trfmod opens a dialog window.


See Also : poly X, simp X



3.133   trianfml symbolic triangularization




CALLING SEQUENCE :

[f [,sexp]]=trianfml(f [,sexp])



DESCRIPTION :

Triangularization of the symbolic matrix f ; triangularization is performed by elementary row operations; sexp is a set of common expressions stored by the algorithm.


EXAMPLE :

A=['1','2';'a','b']
W=trianfml([A,string(eye(2,2))])
U=W(:,3:4)
a=5;b=6;
A=evstr(A)
U=evstr(U)
U*A
evstr(W(:,1:2))



See Also : addf X, mulf X, solve X, trisolve X



3.134   tril lower triangular part of matrix




CALLING SEQUENCE :

tril(x [,k])



PARAMETERS :




DESCRIPTION :

Lower triangle part of a matrix. tril(x,k) is made by entries below the kth diagonal : k>0 (upper diagonal) and k<0 (diagonals below the main diagonal).


EXAMPLE :

s=poly(0,'s');
tril([s,s;s,1])
tril([1/s,1/s;1/s,1])



See Also : triu X, ones X, eye X, diag X



3.135   trisolve symbolic linear system solver




CALLING SEQUENCE :

[x [,sexp]] = trisolve(A,b [,sexp])



PARAMETERS :




DESCRIPTION :

symbolically solves A*x =b , A being assumed to be upper triangular.

sexp
is a vector of common subexpressions in A, b, x.


EXAMPLE :

A=['x','y';'0','z'];b=['0';'1'];
w=trisolve(A,b)
x=5;y=2;z=4;
evstr(w)
inv(evstr(A))*evstr(b)



See Also : trianfml X, solve X


Author : F.D, S.S



3.136   triu upper triangle




DESCRIPTION :

Upper triangle. See tril.



3.137   typeof object type




CALLING SEQUENCE :

[t]=typeof(object)



PARAMETERS :




DESCRIPTION :

t=typeof(object) returns one of the following strings:


EXAMPLE :

typeof(1)
typeof(poly(0,'x'))
typeof(1/poly(0,'x'))
typeof(%t)
w=sprand(100,100,0.001);
typeof(w)
typeof(w==w)
deff('y=f(x)','y=2*x');
typeof(f)



See Also : type X, strings X, syslin X, poly X



3.138   unsetmenu interactive button or menu or submenu de-activation




CALLING SEQUENCE :

unsetmenu(button,[nsub]) 
unsetmenu(gwin,button,[nsub])



PARAMETERS :




DESCRIPTION :

The function allows the user to desactivate buttons or menus created by addmenu in the main or graphics windows command panels.


EXAMPLE :

//addmenu('foo')
//unsetmenu('foo')
//unsetmenu('File',2)



See Also : delmenu X, setmenu X, addmenu X



3.139   x_choices interactive Xwindow choices through toggle buttons




CALLING SEQUENCE :

rep=x_choices(title,items) 



PARAMETERS :




DESCRIPTION :

Select items through toggle lists and return in rep the selected items

Type x_choices()
to see an example.


EXAMPLE :

l1=list('choice 1',1,['toggle c1','toggle c2','toggle c3']);
l2=list('choice 2',2,['toggle d1','toggle d2','toggle d3']);
l3=list('choice 3',3,['toggle e1','toggle e2']);
rep=x_choices('Toggle Menu',list(l1,l2,l3));

3.140   x_choose interactive Xwindow choice




CALLING SEQUENCE :

[num]=x_choose(items,title [,button]) 



PARAMETERS :




DESCRIPTION :

Returns in num the number of the chosen item.


EXAMPLE :

n=x_choose(['item1';'item2';'item3'],['that is a comment';'for the dialog'])
n=x_choose(['item1';'item2';'item3'],['that is a comment'],'Return')



See Also : x_choices X, x_mdialog X, getvalue X, unix_g X



3.141   x_dialog Xwindow dialog




CALLING SEQUENCE :

result=x_dialog(labels,valueini) 



PARAMETERS :




DESCRIPTION :

Creates an X-window multi-lines dialog


EXAMPLE :

//gain=evstr(x_dialog('value of gain ?','0.235'))
//x_dialog(['Method';'enter sampling period'],'1')
//m=evstr(x_dialog('enter a  3x3 matrix ',['[0 0 0';'0 0 0';'0 0 0]']))



See Also : x_mdialog X, x_matrix X, evstr X, execstr X



3.142   x_matrix Xwindow editing of matrix




CALLING SEQUENCE :

[result]=x_matrix(label,matrix-init) 



PARAMETERS :




DESCRIPTION :

For reading or editing a matrix .


EXAMPLE :

//m=evstr(x_matrix('enter a  3x3 matrix ',rand(3,3)))



See Also : x_mdialog X, x_dialog X



3.143   x_mdialog Xwindow dialog




CALLING SEQUENCE :

result=x_mdialog(title,labels,default_inputs_vector) 
result=x_mdialog(title,labelsv,labelsh,default_input_matrix) 



PARAMETERS :




DESCRIPTION :

X-window vector/matrix interactive input function


EXAMPLES :

 txt=['magnitude';'frequency';'phase    '];
 sig=x_mdialog('enter sine signal',txt,['1';'10';'0'])
 mag=evstr(sig(1))
 frq=evstr(sig(2))
 ph=evstr(sig(3))

 rep=x_mdialog(['System Simulation';'with PI regulator'],...
                      ['P gain';'I gain '],[' ';' '])


 n=5;m=4;mat=rand(n,m);
 row='row';labelv=row(ones(1,n))+string(1:n)
 col='col';labelh=col(ones(1,m))+string(1:m)
 new=evstr(x_mdialog('Matrix to edit',labelv,labelh,string(mat)))




See Also : x_dialog X, x_choose X, x_message X, getvalue X, evstr X, execstr X



3.144   x_message X window message




CALLING SEQUENCE :

[num]=x_message(strings [,buttons]) 



PARAMETERS :




DESCRIPTION :

for displaying a message (diagnostic, user-guide ...)




EXAMPLES :

 gain=0.235;x_message('value of gain is :'+string(gain))
 x_message(['singular matrix';'use least squares'])

 r=x_message(['Your problem is ill conditioned';
             'continue ?'],['Yes','No'])



See Also : x_dialog X, x_mdialog X



3.145   xgetfile dialog to get a file path




CALLING SEQUENCE :

path=xgetfile([title='string'])
path=xgetfile(file_mask,[title='string'])
path=xgetfile(file_mask,dir,[title='string'])
path=xgetfile(file_mask,dir,'string')



PARAMETERS :




DESCRIPTION :

Creates a dialog window for file selection


EXAMPLE :

xgetfile()
xgetfile('*.sci','SCI/macros/xdess')
xgetfile(title='Choose a file name ')



See Also : x_dialog X, file X, read X, write X, exec X, getf X



3.146   zeros matrix made of zeros




CALLING SEQUENCE :

[y]=zeros(m,n)
[y]=zeros(x)



PARAMETERS :




DESCRIPTION :

Matrix made of zeros (same as 0*ones). If x is a syslin list (linear system in state-space or transfer form), zeros(x) is also valid and returns a zero matrix.


EXAMPLE :

zeros(3)
zeros(3,3)



See Also : eye X, ones X, spzeros X


Previous Next Contents