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

  1. //-------------------------------------------------------------------------
  2. //
  3. // dgram
  4. //
  5. // Syntax: g=dgram(a,b)
  6. //
  7. // This routine computes the discrete controllability and
  8. // observability gramians. Calling the routine as g=dgram(a,b)
  9. // returns the discrete controllability gramian. Calling the
  10. // routine as g=dgram(a',c') returns the discrete observability
  11. // gramian.
  12. //
  13. // For detail regarding how the gramians are computed, see
  14. // the routine gram (continuous version of dgram).
  15. //
  16. // Ref: Kailath, T. "Linear Systems", Prentice-Hall, 1980.
  17. // Ref: Laub, A., "Computation of Balancing Transformations", Proc. JACC
  18. //      Vol.1, paper FA8-E, 1980.
  19. // Ref: Skelton, R. "Dynamic Systems Control Linear System Analysis and
  20. //      Synthesis," John Wiley and Sons, 1988.
  21. //
  22. // Copyright (C), by Jeffrey B. Layton, 1994
  23. // Version JBL 940918
  24. //-------------------------------------------------------------------------
  25.  
  26. rfile lyap
  27.  
  28. dgram = function(a,b)
  29. {
  30.    local(nargs,A,u,s,g)
  31.  
  32. // Count number of input arguments
  33.    nargs=0;
  34.    if (exist(a)) {nargs=nargs+1;}
  35.    if (exist(b)) {nargs=nargs+1;}
  36.  
  37.    if (nargs != 2) {
  38.        error("DGRAM: Wrong number of input arguments.");
  39.    }
  40.  
  41. // Begin
  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.