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

  1. function [sv] = dsigma2(Z1,Z2,Z3,Z4,Z5,Z6,Z7)
  2. %function [sv] = dsigma2(a,b,c,d,Type,w,Ts)
  3. %
  4. % Discrete Singular Value Frequency Response.
  5. %
  6. % SV = DSIGMA2(A,B,C,D,TYPE,W,Ts) (or optional 
  7. % SV = DSIGMA2(SS_,TYPE,W,Ts) in RCT) produces the matrix SV
  8. % containing the singular values of the square system 
  9. %
  10. %            x[n+1] = Ax[n] + Bu[n]                  
  11. %            y[n]   = Cx[n] + Du[n]
  12. %                                          -1
  13. %     with frequency response G(z) = C(zI-A) B + D.
  14. %
  15. % DSIGMA2 calculates the SVD of one of the following depending on the 
  16. % value of TYPE : 
  17. %
  18. %     Type = 1   ----   G(z)  
  19. %     Type = 2   ----   inv(G(z))
  20. %     Type = 3   ----   I + G(z)
  21. %     Type = 4   ----   I + inv(G(z)) 
  22. %
  23. % Vector W contains the frequencies at which the frequency response
  24. % is to be evaluated. The SV matrix has rows which correspond to the 
  25. % singular values in descending order.
  26. %
  27. % See also DSIGMA for an alternate syntax.
  28.  
  29. % R. Y. Chiang & M. G. Safonov 6/23/87
  30. % Revised W. Wang 7/24/92
  31. % Copyright (c) 1986-93 by the MathWorks, Inc.
  32. % All Rights Reserved.
  33. % ------------------------------------------------------------------------
  34. %
  35.  
  36. if exist('mkargs') == 2, %If RCT installed
  37.   cmd=[];
  38.   inargs = '(a,b,c,d,Type,w,Ts)';
  39.   eval('cmd=mkargs(inargs,nargin,''ss'');')
  40.   eval(cmd)
  41. else                       % If RCT not installed
  42.   % assign a=Z1;...,Type=Z5;w=Z6;Ts=Z7;
  43.   if nargin<4,
  44.     error('Too few input arguments')
  45.   else
  46.     a=Z1; b=Z2; c=Z3; d=Z4;
  47.     if nargin>6,
  48.       Ts=Z7;
  49.     elseif nargin>5,
  50.       w=Z6;
  51.     elseif nargin>4,
  52.       Type=Z5;
  53.     end
  54.   end
  55. end;
  56.  
  57. disp('  ')
  58. disp('          ..... Working ...... please wait .....')
  59. [mg] = dfreqrc(a,b,c,d,w,Ts);
  60. [rmg,cmg] = size(mg);
  61. [rb,cb] = size(b);
  62. [rc,cc] = size(c);
  63. gg = ones(rc,cb);
  64. for is = 1 : cmg
  65.   gg(:) = mg(:,is);
  66.   if (Type == 1)
  67.     sv(:,is) = svd(gg);
  68.   end
  69.   if (Type == 2)
  70.     sv(:,is) = svd(inv(gg));
  71.   end
  72.   if (Type == 3)
  73.     sv(:,is) = svd(eye(cb) + gg);
  74.   end
  75.   if (Type == 4)
  76.     sv(:,is) = svd(eye(cb) + inv(gg));
  77.   end
  78. end
  79. %
  80. % ----- End of DSIGMA.M ---- RYC/MGS 6/23/87 %
  81.