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

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