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

  1. function [ab,bb,cb,db] = dmodred(a,b,c,d,elim)
  2. %DMODRED Discrete-time model state reduction.
  3. %    [Ab,Bb,Cb,Db] = DMODRED(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[n+1] = Ax[n] + Bu[n],   y[n] = Cx[n] + Du[n]
  11. %
  12. %    X2[n+1] is set to X2[n], and the resulting equations solved for
  13. %    X1.  The resulting system has LENGTH(ELIM) fewer states and can be
  14. %    envisioned as having set the ELIM states to be infinitely fast.
  15. %
  16. %    See also DBALREAL, BALREAL and MODRED
  17.  
  18. %    J.N. Little 9-4-86
  19. %    Revised 8-26-87 JNL
  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. [mk,nk] = size(a11);
  41. a22 = a22 - eye(ns-mk);
  42. ab  = a11 - a12/a22*a21;
  43. bb  = b1 - a12/a22*b2;
  44. cb  = c1 - c2/a22*a21;
  45. db  = d - c2/a22*b2;
  46.