home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / MODRED.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.1 KB  |  44 lines

  1. function [ab,bb,cb,db] = modred(a,b,c,d,elim)
  2. %MODRED Model state reduction.
  3. %    [Ab,Bb,Cb,Db] = MODRED(A,B,C,D,ELIM) reduces the order of a model
  4. %    by eliminating the states specified in vector ELIM.  The state
  5. %    vector is partioned into X1, to be kept, and X2, to be eliminated,
  6. %
  7. %        A = |A11  A12|        B = |B1|    C = |C1 C2|
  8. %            |A21  A22|            |B2|
  9. %        .
  10. %        x = Ax + Bu,   y = Cx + Du
  11. %
  12. %    The derivative of X2 is set to zero, and the resulting equations
  13. %    solved for X1.  The resulting system has LENGTH(ELIM) fewer states
  14. %    and can be envisioned as having set the ELIM states to be 
  15. %    infinitely fast.
  16. %
  17. %    See also BALREAL and DMODRED
  18.  
  19. %    J.N. Little 9-4-86
  20. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  21.  
  22. error(abcdchk(a,b,c,d));
  23.  
  24. % Form keep vector:
  25. [ns,nu] = size(b);
  26. keep = 1:ns;
  27. keep(elim) = [];
  28.  
  29. % Partition into x1, to be kept, and x2, to be eliminated:
  30. a11 = a(keep,keep);
  31. a12 = a(keep,elim);
  32. a21 = a(elim,keep);
  33. a22 = a(elim,elim);
  34. b1  = b(keep,:);
  35. b2  = b(elim,:);
  36. c1  = c(:,keep);
  37. c2  = c(:,elim);
  38.  
  39. % Form final reduced matrices
  40. ab  = a11 - a12/a22*a21;
  41. bb  = b1 - a12/a22*b2;
  42. cb  = c1 - c2/a22*a21;
  43. db  = d - c2/a22*b2;
  44.