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

  1. function zpplot(zepo,sd,mode,ax)
  2. %ZPPLOT  Plots zeros and poles.
  3. %
  4. %    zpplot(ZEPO)   or   zpplot(ZEPO,SD)  or  zpplot(ZEPO,MODE)
  5. %               or   zpplot(ZEPO,SD,MODE,AXIS)
  6. %
  7. %    The zeros and poles, specified by ZEPO (See TH2ZP, or ZPFORM 
  8. %    for the format) are plotted, with 'o' denoting zeros and 'x' poles.
  9. %    Poles and zeros    associated with the same input, but different models
  10. %    are always plotted in the same diagram, and 'ENTER' advances the plot 
  11. %    from one model to the next (if any).
  12. %
  13. %    When ZEPO contains information about several different inputs there
  14. %    are some options: 
  15. %    MODE='sub' (The default value) splits the screen into several plots.
  16. %    MODE='same' gives all plots in the same diagram. Use 'ENTER' to advance
  17. %    MODE='sep' erases the previous plot before the next input is treated.
  18. %       AXIS=[x1 x2 y1 y2] fixes the axes scaling.
  19. %    AXIS=m is the same as AXIS=[-m m -m m]. Default is autoscaling
  20. %    If SD>0, confidence regions around the poles and zeros are plotted.
  21. %    The region corresponding to SD standard deviations is marked.
  22. %    SD=0 is default.
  23. %    For multi-output models, each output is handled separately.
  24.  
  25. %    L. Ljung 10-1-86, revised 7-3-87,2-10-92
  26. %    Copyright (c) 1986-92 by the MathWorks, Inc.
  27. %    All Rights Reserved.
  28.  
  29. % Some intial tests on the input arguments
  30. if nargin<4, ax=[];end
  31. if nargin<3, mode=[];end
  32. if nargin<2,sd=0;end, if isempty(sd),sd=0;end,if sd<0, sd=0;end
  33. if length(sd)>1 mode=sd; sd=0;end
  34. if isempty(ax),axdef=1; else axdef=0;end
  35. if isempty(mode),mode='sub';end
  36. mode=mode(1:3);
  37. if mode=='sub',sbflag=1;else sbflag=0;end
  38. [nzp,nc]=size(zepo);
  39. if fix(nc/2)~=nc/2
  40.   error('ZEPO should have an even number of columns')
  41. end
  42.  
  43. %
  44. colors=['g','b','r','w'];
  45. zsc=zepo;
  46. if any(any(zsc==inf));ztemp=zsc(:);
  47. ztemp(find(ztemp==inf))=zeros(length(find(ztemp==inf)),1);zsc(:)=ztemp;end
  48. om=2.1*pi*[1:100]/100;
  49. w=exp(om*sqrt(-1));
  50.  
  51. inputs1=zepo(1,:);
  52. if abs(sum(sign(inputs1)))~=nc
  53. disp(['WARNING: ZEPO contains a mixture of discrete and continuous models.'...
  54. '\nPress a key to continue, C-c to abort']),pause,end
  55. T=sign(inputs1(1));inputs1=abs(inputs1);zepo(1,:)=inputs1;
  56. mo=fix(inputs1/1000);mmo=max(mo);
  57. kko=[]; % The output indices
  58. for k=[0:mmo],if length(find(mo==k))>0,kko=[kko k];end,end
  59.  
  60. for ko=kko+1
  61. inputs=inputs1-(ko-1)*1000;
  62.  
  63. kki=[]; mi=max(inputs(find(inputs<20)));% The input indices
  64. mino=max(inputs(find(inputs>500 & inputs<520)));
  65. for ki=[1:mi 501:mino]
  66. if length(find(inputs==ki))>0,kki=[kki ki];end
  67. end
  68.  
  69. clf reset
  70. space=[];
  71. sbcount = 0;
  72. if mode=='sub' & norm(kki-kki(1)*ones(1,length(kki)))>0,
  73.    sbcount=1;end
  74. if mode=='sam',mm=max(max(abs(zsc(2:nzp,find((inputs)/60<1)))));
  75.     m=ceil(mm);if T<0,mar=max(max(real(zsc(2:nzp,find((inputs)/60<1)))));
  76.     mir=min(min(real(zsc(2:nzp,find((inputs)/60<1)))));end
  77.     
  78. end
  79. for ki=kki
  80.     inpc=find((inputs==ki) | (inputs==ki+20));
  81.     insd=find((inputs==ki+60) | (inputs==ki+80));
  82.     if sum(mode~='sam')>0,
  83.        mm=max(max(abs([zsc(2:nzp,inpc)]))); m=ceil(mm);
  84.        if T<0,mar=max(max(real([zsc(2:nzp,inpc)]))); 
  85.        mir=min(min(real([zsc(2:nzp,inpc)]))); end
  86.     end
  87.  
  88.  
  89.     if ~axdef m=ax; end
  90.     if length(m)==1, m1=m;m(1)=-m1;m(2)=m1;m(3)=-m1;m(4)=m1;end
  91.     if sbflag & sbcount>0,subplot(220+sbcount),end
  92.     plot([m(1);m(2)],[m(3);m(4)],'i.'),axis(axis)
  93.     axis('square'),
  94.  
  95.     
  96.     hold on
  97.     if sum(mode~='sam')>0
  98.        if ki<500 ,title(['OUTPUT # ',int2str(ko),'  INPUT # ',int2str(ki)])
  99.        else title(['OUTPUT # ',int2str(ko),'  NOISE INPUT # ',int2str(rem(ki,500))])
  100.        end
  101.     else text(0.3,1.03,['OUTPUT # ',int2str(ko),' INPUT # ',space,int2str(ki)],'sc')
  102.     space=[space,'  '];
  103.     end
  104.  
  105.     if T>0,plot(w),end %The unit circle
  106.     count=0;
  107.     for k=inpc
  108.         colind=rem(count/2,4)+1;count=count+1;
  109.         if k+1>nc,sdpl=0;info=zepo(1,k)-1000*(ko-1);
  110.     if info>500,info=info-500;end
  111.     else info=zepo(1,k:k+1)-1000*(ko-1);if info(1,1)>500,info=info-500;end
  112.     sdpl=((info(1,2)==info(1,1)+60)&sd>0);
  113.     end
  114.     if sdpl
  115.        zp=zepo(2:nzp,k:k+1);
  116.     else zp=zepo(2:nzp,k);
  117.     end
  118.     iz=find(abs(zp(:,1))<1/eps);
  119.     if T>0,iz=find((abs(zp(:,1))>0).*(abs(zp(:,1))<1/eps));end
  120.     if length(iz)>0
  121.           if fix(info(1,1)/20)==0,mark1='o';mark2='-.';mark3='-';
  122.       else mark1='x';mark2=':';mark3='-';
  123.       end
  124.       mark1=[mark1,colors(colind)];
  125.       mark2=[mark2,colors(colind)];
  126.       mark3=[mark3,colors(colind)];
  127.           plot(real(zp(iz,1)),imag(zp(iz,1)),mark1)
  128.       if sdpl,zpsdpl(zp,sd,w,iz',mark2,mark3),end
  129.         end
  130.     if fix(info(1,1)/20)>0 & k~=inpc(length(inpc)), pause,end
  131.     end
  132.     if sbflag,sbcount=sbcount+1;
  133.     if sbcount>4,sbcount=1;end,end
  134.     if sum(mode~='sam')>0 ,hold off,end
  135.     if ki~=kki(length(kki)),pause,end
  136. end
  137. if ko~=kko(length(kko))+1,pause,hold off,end
  138. end
  139.  
  140. hold off
  141.  
  142. set(gcf,'NextPlot','replace');
  143.