1
function [a,b,c,d]=lin(sim,x0,u0)
2
//Syntaxes : sl=lin(sim,x0,u0) or
3
// [a,b,c,d]=lin(sim,x0,u0)
5
//linearization of the non-linear differential system [y,xdot]=sim(x,u)
6
//around x0 , u0. (sim is a scilab macro which computes y and xdot).
8
//- linear system sl (syslin list)
11
// Example : Let ftz be the function passed to ode e.g.
12
// [zd]=ftz(t,z,u), and let us assume y=x.
13
// [z]=ode(x0,t0,tf,list(ftz,u) compute x(tf)
14
// Let simula be the followinf function:
15
// function [y,xd]=simula(x,u)
16
// xd=ftz(tf,x,u); y=x;
18
// The tangent linear system sl is obtained by:
19
// [a,b,c,d]=lin(simula,z,u)
20
// sl = syslin('c',a,b,c,d,x0)
24
[n,w]=size(x0);[m,w]=size(u0);mpn=m+n
25
nrm=norm([x0;u0]);if nrm<1 then nrm=1,end;
26
[zz,nu]=colcomp(rand(mpn,mpn));
27
d=10*%eps*nrm*zz(:,1:nu); [y,xd]=sim(x0,u0); y0=[xd;y];
28
ab=[];for v=d,[y,xd]=sim(x0+v(1:n),u0+v(n+1:mpn)),
29
ab=[ab,([xd;y]-y0)],end
31
ab=ab/d;a=ab(1:n,1:n);b=ab(1:n,n+1:mpn)
32
c=ab(n+1:n+p,1:n);d=ab(n+1:n+p,n+1:mpn)
33
if lhs==1 then a=syslin('c',a,b,c,d,x0),end