home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- //
- // gram
- //
- // Syntax: g=gram(a,b)
- //
- // This routine computes the Controllability and observability
- // gramians. Calling the routine as A=gram(a,b) returns the
- // controllability gramian:
- //
- // Gc = integral {exp(at)bb'exp(a't)} dt
- //
- // Calling the routine as A=gram(a',c') returns the
- // observability gramian:
- //
- // Go = integral {exp(ta')c'cexp(ta)} dt
- //
- // Ref: Laub, A., "Computation of Balancing Transformations", Proc. JACC
- // Vol.1, paper FA8-E, 1980.
- // Ref: Skelton, R. "Dynamic Systems Control Linear System Analysis and
- // Synthesis," John Wiley and Sons, 1988.
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940918
- //---------------------------------------------------------------------------
-
- rfile lyap
-
- gram = function(a,b)
- {
- local(nargs,A,u,s,g)
-
- // Count number of input arguments
- nargs=0;
- if (exist(a)) {nargs=nargs+1;}
- if (exist(b)) {nargs=nargs+1;}
-
- if (nargs != 2) {
- error("GRAM: Wrong number of input arguments");
- }
-
- A=svd(b);
- u=A.u
- s=A.sigma;
-
- g=u*lyap(u'*a*u,s*s')*u';
-
- return g
- };
-