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

  1. function [p,q] = dcovar(a,b,c,d,w)
  2. %DCOVAR Covariance response of discrete system to white noise.
  3. %    [P,Q] = DCOVAR(A,B,C,D,W) computes the covariance response of the 
  4. %    discrete state-space system (A,B,C,D) to Gaussian white noise
  5. %    inputs with intensity W,
  6. %
  7. %        E[w(k)w(n)'] = W delta(k,n)
  8. %
  9. %    where delta(k,n) is the kronecker delta.  P and Q are the output
  10. %    and state covariance response:
  11. %
  12. %        P = E[yy'];  Q = E[xx'];
  13. %
  14. %    P = DCOVAR(NUM,DEN,W) computes the output covariance response of
  15. %    the polynomial transfer function system.  W is the intensity of 
  16. %    the input noise.
  17. %
  18. %    See also: COVAR,LYAP and DLYAP.
  19.  
  20. %    Clay M. Thompson  7-5-90
  21. %       Revised by Wes Wang 8-5-92
  22. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  23.  
  24. error(nargchk(3,5,nargin));
  25. if ~((nargin==3)|(nargin==5)), error('Wrong number of input arguments.'); end
  26.  
  27. % --- Determine which syntax is being used ---
  28. if (nargin == 3) % T.F. syntax
  29.   [num,den] = tfchk(a,b);
  30.   w = c;
  31.   [a,b,c,d] = tf2ss(num,den);
  32. end
  33.  
  34. if (nargin==5), error(abcdchk(a,b,c,d)); end
  35.  
  36. q = dlyap(a,b*w*b');
  37. p = c*q*c' + d*w*d';
  38.  
  39. % A valid covariance must be positive semi-definite.
  40. if min(real(eig(q))) < -eps,
  41.   if max(abs(eig(a))) > 1
  42.     disp('Warning: Unstable system. Returning infinity.')
  43.   else
  44.     disp('Warning: Invalid covariance - not positive semi-definite.  Returning infinity.')
  45.   end;
  46.   q = inf*ones(length(q)); p = inf*ones(length(p));
  47. end
  48.