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

  1. function [cg,ph] = dcgloci2(Z1,Z2,Z3,Z4,Z5,Z6,Z7)
  2. %
  3. % Discrete Characteristic Gain/Phase Frequency Response.
  4. %
  5. % [CG,PH] = DCGLOCI2(SS_, Type, W, Ts) or
  6. % [CG,PH] = DCGLOCI2(A, B, C, D, Type, W, Ts) produces the matrix G & PH 
  7. % containing the characteristic Gain/Phase values for the discrete system
  8. % sampled at Ts sec:
  9. %              
  10. %                x(k+1) = Ax(k) + Bu(k)
  11. %                y(k) = Cx(k) + Du(k)
  12. %                                                   -1
  13. %     with the frequency response G(z) = C(zI - A)  B + D.
  14. % DCGLOCI calculates the eigenvalues of one of the following depending 
  15. % on the value of Type : 
  16. %
  17. %     Type = 1   ----   char( G(z) ) 
  18. %     Type = 2   ----   char( inv( G(z) ) )
  19. %     Type = 3   ----   char( I + G(z) ) 
  20. %     Type = 4   ----   char( I + inv( G(z) ) 
  21. %
  22. % Vector W contains the frequencies at which the frequency response
  23. % is to be evaluated.  The CG and PH matrices have rows
  24. % which correspond to the char. gain/phase in decending order.
  25. %
  26.  
  27. % R. Y. Chiang & M. G. Safonov 6/29/87
  28. % Copyright (c) 1988 by the MathWorks, Inc.
  29. % All Rights Reserved.
  30. % -----------------------------------------------------------------------
  31. %
  32.  
  33. inargs='(a,b,c,d,Type,w,Ts)';
  34. eval(mkargs(inargs,nargin,'ss'))
  35.  
  36. [mg] = dfreqrc(a,b,c,d,w,Ts);
  37. [rmg,cmg] = size(mg);
  38. [rb,cb] = size(b);
  39. [rc,cc] = size(c);
  40. gg = ones(rc,cb);
  41. for is = 1 : cmg
  42.   gg(:) = mg(:,is);
  43.   if (Type == 1)
  44.     char = eig(gg);
  45.     cg(:,is) = sort(abs(char)); 
  46.     ph(:,is) = sort(180./pi*imag(log(char))); 
  47.   end
  48.   if (Type == 2)
  49.     char = eig(inv(gg));
  50.     cg(:,is) = sort(abs(char));
  51.     ph(:,is) = sort(180./pi*imag(log(char)));
  52.   end
  53.   if (Type == 3)
  54.     [tmp1,tmp2]=size(gg);
  55.     char = eig(eye(tmp1,tmp2)+gg);
  56.     cg(:,is) = sort(abs(char)); 
  57.     ph(:,is) = sort(180./pi*imag(log(char))); 
  58.   end
  59.   if (Type == 4)
  60.     [tmp1,tmp2]=size(gg);
  61.     char = eig(eye(tmp1,tmp2)+inv(gg));
  62.     cg(:,is) = sort(abs(char)); 
  63.     ph(:,is) = sort(180./pi*imag(log(char))); 
  64.   end
  65. end
  66. cg = cg(cb:-1:1,:);
  67. ph = ph(cb:-1:1,:);
  68. %
  69. % ----- End of DCGLOCI2.M ---- RYC/MGS 6/29/87 %
  70.