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

  1. %
  2. % Preparing plots for evaluating H2 or H-inf design performance
  3. %
  4. %             Inputs: ag,bg,cg,dg, nuw1i,dnw1i, nuw3i,dnw3i
  5. %
  6.  
  7. % R. Y. Chiang & M. G. Safonov 6/86
  8. % Copyright (c) 1988 by the MathWorks, Inc.
  9. % All Rights Reserved.
  10. % ----------------------------------------------------------------
  11. clc
  12. disp('  ')
  13. disp('     ..... Evaluating performance ..... Please wait .....')
  14. flagga = exist('Gam');
  15. if flagga < 1
  16.    Gam = input('   Input cost function coefficient "Gam" = ');
  17. end
  18. % -------------------------------------------------------------------
  19. [rdg,cdg] = size(dg);
  20. %
  21. [al,bl,cl,dl] = series(acp,bcp,ccp,dcp,ag,bg,cg,dg);
  22. if rdg == 1 & cdg == 1
  23.   disp('  ')
  24.   disp('     ..... Computing Bode plot of the cost function .....')
  25.   svtt = sigma(acl,bcl,ccl,dcl,1,w); svtt = 20*log10(svtt);
  26.   maxsvtt = max(svtt(1,:));  minsvtt = min(svtt(size(svtt)*[1;0],:));
  27.   deltasv = abs(maxsvtt-minsvtt);
  28.   disp(' ')
  29.   disp('  ')
  30.   disp('      (strike a key to see the plot of the cost function (Ty1u1) ...)')
  31.   pause
  32.   clg
  33.   semilogx(w,svtt)
  34.   title(['COST FUNCTION Ty1u1 (Gam = ' num2str(Gam) ')'])
  35.   xlabel('Frequency - Rad/Sec')
  36.   ylabel('SV - db')
  37.   text(0.01,maxsvtt-deltasv/4,'Is this design close enough ?');
  38.   text(0.01,maxsvtt-deltasv/2,'(if not, adjust the cost function and try again..)');
  39.   grid
  40.   pause
  41.   disp('  ')
  42.   disp(' ')
  43.   disp('               (strike a key to continue or hit <CTRL-C> to quit ...)')
  44.   pause
  45.   disp(' ')
  46.   disp('     ..... Computing Bode plots of Sens. & Comp. Sens. functions .....')
  47.   [als,bls,cls,dls] = feedbk(al,bl,cl,dl,1);
  48.   [at,bt,ct,dt] = feedbk(al,bl,cl,dl,2);
  49.   svs = bode(als,bls,cls,dls,1,w); svs = 20*log10(svs);
  50.   svt = bode(at,bt,ct,dt,1,w); svt = 20*log10(svt);
  51.   svw1i = bode(nuw1i,Gam*dnw1i,w); svw1i = 20*log10(svw1i);
  52.   svw3i = bode(nuw3i,dnw3i,w); svw3i = 20*log10(svw3i);
  53.   disp(' ')
  54.   disp(' ')
  55.   disp('           (strike a key to see the plots of Sens. & Comp. Sens. ...)')
  56.   pause
  57.   clg
  58.   semilogx(w,svw1i,w,svs)
  59.   title('SENSITIVITY FUNCTION AND 1/W1');
  60.   xlabel('Frequency - Rad/Sec')
  61.   ylabel('Gain - db')
  62.   grid
  63.   pause
  64.   semilogx(w,svw3i,w,svt)
  65.   title('COMP. SENSITIVITY FUNCTION AND 1/W3');
  66.   xlabel('Frequency - Rad/Sec')
  67.   ylabel('Gain - db')
  68.   grid
  69.   pause
  70.   disp(' ')
  71.   disp('     ..... Computing Nichols plot & stability margin .....')
  72.   [gal,phl] = bode(al,bl,cl,dl,1,w); 
  73.   [Gmarg,Pmarg,Wcg,Wcp] = margin(gal,phl,w);
  74.   Gmarg = 20*log10(Gmarg);
  75.   gal = 20*log10(gal);
  76.   disp(' ')
  77.   disp(' ')
  78.   disp('                 (strike a key to see the Nichols plot of L(s) ...)')
  79.   pause
  80.   clg
  81.   plot(phl,gal)
  82.   maxphl = max(phl);  minphl = min(phl);  delphl = abs(maxphl-minphl);  
  83.   maxgal = max(gal);  mingal = min(gal);  delgal = abs(maxgal-mingal);
  84.   text(minphl,mingal+delgal/2,...
  85.   [' GAIN MARGIN  = ' num2str(Gmarg) ' db at ' num2str(Wcg) ' rad/sec'])
  86.   text(minphl,mingal+delgal/4,...
  87.   [' PHASE MARGIN = ' num2str(Pmarg) ' deg at ' num2str(Wcp) ' rad/sec'])
  88.   title('NICHOLS PLOT')
  89.   xlabel('Phase -- deg')
  90.   ylabel('Gain -- db')
  91.   grid
  92.   pause
  93. else
  94.   disp('  ')
  95.   disp('     ..... Computing the SV Bode plot of Ty1u1 .....')
  96.   svtt = sigma(acl,bcl,ccl,dcl,1,w); svtt = 20*log10(svtt);
  97.   maxsvtt = max(svtt(1,:));  minsvtt = min(svtt(size(svtt)*[1;0],:));
  98.   deltasv = abs(maxsvtt-minsvtt);
  99.   disp(' ')
  100.   disp('  ')
  101.   disp('      (strike a key to see the plot of the cost function (Ty1u1) ...)')
  102.   pause
  103.   clg
  104.   semilogx(w,svtt)
  105.   title(['COST FUNCTION Ty1u1 (Gam = ' num2str(Gam) ')'])
  106.   xlabel('Frequency - Rad/Sec')
  107.   ylabel('SV - db')
  108.   text(0.01,maxsvtt-deltasv/4,'Is this design close enough ?');
  109.   text(0.01,maxsvtt-deltasv/2,'(if not, adjust the cost function and try again..)');
  110.   grid
  111.   pause
  112.   disp('  ')
  113.   disp(' ')
  114.   disp('               (strike a key to continue or hit <CTRL-C> to quit ...)')
  115.   pause
  116.   disp(' ')
  117.   disp('     ..... Computing the SV Bode plots of Sens. & Comp. Sens. .....')
  118.   svs = sigma(al,bl,cl,dl,3,w); svs = -20*log10(svs);
  119.   [at,bt,ct,dt] = feedbk(al,bl,cl,dl,2);
  120.   svt = sigma(at,bt,ct,dt,1,w); svt = 20*log10(svt);
  121.   svw1i = bode(nuw1i,Gam*dnw1i,w); svw1i = 20*log10(svw1i);
  122.   svw3i = bode(nuw3i,dnw3i,w); svw3i = 20*log10(svw3i);
  123.   disp(' ')
  124.   disp(' ')
  125.   disp('           (strike a key to see the plots of Sens. & Comp. Sens. ...)')
  126.   pause
  127.   clg
  128.   semilogx(w,svw1i,w,svs)
  129.   title('SENSITIVITY FUNCTION AND 1/W1');
  130.   xlabel('Frequency - Rad/Sec')
  131.   ylabel('SV - db')
  132.   grid
  133.   pause
  134.   semilogx(w,svw3i,w,svt)
  135.   title('COMP. SENSITIVITY FUNCTION AND 1/W3');
  136.   xlabel('Frequency - Rad/Sec')
  137.   ylabel('SV - db')
  138.   grid
  139.   pause
  140. end
  141. %
  142. if rdg == 1 & cdg == 1
  143.    disp('  ')
  144.    disp('                 << Plot variable names >>')
  145.    disp('---------------------------------------------------------------')
  146.    disp(' w ------ freqeuncy (rad/sec)')
  147.    disp(' gal, phl ---- gain & phase of L(jw) (loop transfer fucntion)')
  148.    disp(' svs ---- Bode plot of S(jw) (sensitivity)')
  149.    disp(' svt ---- Bode plot of I-S(jw) (complementary sensitivity)')
  150.    disp(' svtt --- Bode plot of the cost function (Ty1u1(jw))')
  151.    disp(' svw1i --- Bode plot of 1/W1(jw) weighting function')
  152.    disp(' svw3i --- Bode plot of 1/W3(jw) weighting function')
  153.    disp('---------------------------------------------------------------')
  154. else   
  155.    disp(' ')
  156.    disp('                 << Plot variable names >>')
  157.    disp('---------------------------------------------------------------')
  158.    disp(' w ------ freqeuncy (rad/sec)')
  159.    disp(' svs ---- singular values of S(jw) (sensitivity)')
  160.    disp(' svt ---- singular values of I-S(jw) (complementary sensitivity)')
  161.    disp(' svtt --- singular values of the cost function (Ty1u1(jw))')
  162.    disp(' svw1i --- singular values of 1/W1(jw) weighting function')
  163.    disp(' svw3i --- singular values of 1/W3(jw) weighting function')
  164.    disp('---------------------------------------------------------------')
  165. end
  166. %
  167. % -------- End of PLTOPT.M --- RYC/MGS 
  168.