home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / languages / rlab1_23a / CTB / augstate < prev    next >
Text File  |  1995-11-14  |  1KB  |  60 lines

  1. //-------------------------------------------------------------------------
  2. //
  3. // augstate
  4. //
  5. // Syntax: G=augstate(a,b,c,d)
  6. //
  7. // This routine augments the outputs of a state-space system with the
  8. // states of the system. Calling the routine as G=augstate(A,B,C,D)
  9. // produces the following augmented system:
  10. //              .
  11. //              x = Ax + Bu
  12. // 
  13. //             |y| = |C| x + |D| u
  14. //             |x|   |I|     |0|
  15. // 
  16. // The results are returned in a list:
  17. //
  18. //     G.aa = augmented A matrix (no change from input)
  19. //     G.ba = augmented B matrix (no change from input)
  20. //     G.ca = augmented C matrix
  21. //     G.da = augmented D matrix
  22. //
  23. // Copyright (C), by Jeffrey B. Layton
  24. // Version JBL 940922
  25. //-------------------------------------------------------------------------
  26.  
  27. rfile abcdchk
  28.  
  29. augstate = function(a,b,c,d)
  30. {
  31.    local(nargs,msg,estr,aa,ba,ca,da)
  32.  
  33. // Count number of arguments
  34.    nargs=0;
  35.    if (exist(a)) {nargs=nargs+1;}
  36.    if (exist(b)) {nargs=nargs+1;}
  37.    if (exist(c)) {nargs=nargs+1;}
  38.    if (exist(d)) {nargs=nargs+1;}
  39.  
  40.    if (nargs != 4) {
  41.        error("AUGSTATE: Wrong number of input arguments.");
  42.    }
  43.  
  44. // Check input system
  45.    msg="";
  46.    msg=abcdchk(a,b,c,d);
  47.    if (msg != "") {
  48.        estr="AUGSTATE: "+msg;
  49.        error(estr);
  50.    }
  51.  
  52. // Augment
  53.    aa=a;
  54.    ba=b;
  55.    ca=[c;eye(a.nr,a.nc)];
  56.    da=[d;zeros(a.nr,d.nc)];
  57.  
  58.    return << aa=aa; ba=ba; ca=ca; da=da >>
  59. };
  60.