home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / r / rlab / CTB / gram < prev    next >
Encoding:
Text File  |  1995-11-15  |  1.1 KB  |  50 lines

  1. //---------------------------------------------------------------------------
  2. //
  3. // gram
  4. //
  5. // Syntax: g=gram(a,b)
  6. //
  7. // This routine computes the Controllability and observability
  8. // gramians. Calling the routine as A=gram(a,b) returns the
  9. // controllability gramian:
  10. //
  11. //        Gc = integral {exp(at)bb'exp(a't)} dt
  12. //
  13. // Calling the routine as A=gram(a',c') returns the 
  14. // observability gramian:
  15. //
  16. //        Go = integral {exp(ta')c'cexp(ta)} dt
  17. //
  18. // Ref: Laub, A., "Computation of Balancing Transformations", Proc. JACC
  19. //      Vol.1, paper FA8-E, 1980.
  20. // Ref: Skelton, R. "Dynamic Systems Control Linear System Analysis and
  21. //      Synthesis," John Wiley and Sons, 1988.
  22. //
  23. // Copyright (C), by Jeffrey B. Layton, 1994
  24. // Version JBL 940918
  25. //---------------------------------------------------------------------------
  26.  
  27. rfile lyap
  28.  
  29. gram = function(a,b)
  30. {
  31.    local(nargs,A,u,s,g)
  32.  
  33. // Count number of input arguments
  34.    nargs=0;
  35.    if (exist(a)) {nargs=nargs+1;}
  36.    if (exist(b)) {nargs=nargs+1;}
  37.  
  38.    if (nargs != 2) {
  39.        error("GRAM: Wrong number of input arguments");
  40.    }
  41.  
  42.    A=svd(b);
  43.    u=A.u
  44.    s=A.sigma;
  45.  
  46.    g=u*lyap(u'*a*u,s*s')*u';
  47.  
  48.    return g
  49. };
  50.