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

  1. function [ae,be,ce,de] = estim(a,b,c,d,l,e,f)
  2. %ESTIM Form continuous Kalman estimator.
  3. %    [Ae,Be,Ce,De] = ESTIM(A,B,C,D,L) produces the Kalman estimator 
  4. %    based on the continuous system (A,B,C,D) with Kalman gain matrix
  5. %    L assuming all the outputs of the system are sensor outputs.  The
  6. %    resulting state-space estimator is
  7. %          .
  8. %         xHat  = [A-LC] xHat + Ly
  9. %
  10. %        |yHat| = |C| xHat
  11. %        |xHat|   |I|
  12. %
  13. %    and has estimated sensors yHat and estimated states xHat as 
  14. %    outputs, and sensors y as inputs.  
  15. %
  16. %    [Ae,Be,Ce,De] = ESTIM(A,B,C,D,L,SENSORS,KNOWN) forms the Kalman 
  17. %    estimator using the sensors specified by SENSORS, and the 
  18. %    additional known inputs specified by KNOWN.  The resulting system
  19. %    has estimated sensors and states as outputs, and the known inputs
  20. %    and sensors as inputs.  The KNOWN inputs are non-stochastic inputs
  21. %    of the plant and are usually control inputs.
  22. %
  23. %     See also: REG,DCONTROL,DESTIM,LQR,DLQR,LQE and DLQE.
  24.  
  25. %    Clay M. Thompson 7-2-90
  26. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  27.  
  28. error(nargchk(5,7,nargin));
  29. if ~((nargin==5)|(nargin==7)), error('Wrong number of input arguments.'); end
  30.  
  31. error(abcdchk(a,b,c,d));
  32.  
  33. [nx,na] = size(a);
  34. [ny,nu] = size(d);
  35.  
  36. if (nargin==5)
  37.   sensors = [1:ny]; known = [];
  38. end
  39. if (nargin==7)
  40.   sensors = e; known = f;
  41. end
  42.  
  43. nsens = length(sensors); nknown = length(known);
  44.  
  45. % Check size of L with number of states and sensors
  46. [nl,ml] = size(l);
  47. if (ml~=nsens)
  48.   error('Number of sensors and size of L matrix don''t match.'); end
  49. if (nl~=nx)
  50.   error('The A and L matrices must have the same number of rows.'); end
  51.  
  52. inputs = [1:nsens] + nu; states = [1:nx] + ny;
  53.  
  54. % --- Form continuous Kalman estimator ---
  55. ae = a;
  56. be = [b,l];
  57. ce = [c;eye(nx)];
  58. de = [d, zeros(ny,nsens);zeros(nx,nu), zeros(nx,nsens)];
  59.  
  60. % close sensor feedback loop
  61. [ae,be,ce,de] = cloop(ae,be,ce,de,sensors,-inputs);
  62. [ae,be,ce,de] = ssselect(ae,be,ce,de,[known,inputs],[sensors,states]);
  63.