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

  1. function [cg,ph] = mulerr(a0,b0,c0,d0,a,b,c,d,w,opt)
  2. % [CG,PH] = MULERR(A0,B0,C0,D0,A,B,C,D,W,OPT) produce a multiplicative
  3. % error frequency response plot between two models (A0,B0,C0,D0) and 
  4. % (A,B,C,D). The optional input "opt" determines the computing methods:
  5. %
  6. %          OPT = 1, Singular Values
  7. %          OPT = 2, Characteristic Gain Loci
  8. %
  9.  
  10. % R. Y. Chiang & M. G. Safonov
  11. %
  12. if nargin < 10
  13.    opt = 2;
  14. end
  15. %
  16. j = sqrt(-1);
  17. ls = size(w)*[0;1];
  18. %
  19. siz = size(d0);
  20. g0jw = zeros(siz(1),siz(2));
  21. gjw  = zeros(siz(1),siz(2));
  22. %
  23. g0jwt = freqrc(a0,b0,c0,d0,w);
  24. gjwt  = freqrc(a,b,c,d,w);
  25. %
  26. for i = 1:ls
  27.   g0jw(:) = g0jwt(:,i);
  28.   gjw(:)  = gjwt(:,i);
  29.   Z = (g0jw - gjw) / g0jw;
  30.   if opt == 1
  31.    sv = svd(Z);
  32.    cg(:,i) = sv;
  33.   else
  34.    chgain = eig(Z);
  35.    [y,ind] = sort(-abs(chgain));
  36.    cg(:,i) = -y;
  37.    [x,ind] = sort(-180./pi*imag(log(chgain)));
  38.    ph(:,i) = -x;
  39.   end
  40. end
  41. %
  42. % -------- End of MULERR.M % RYC/MGS
  43.