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

  1. function ffplot(G,sd,C,mode)
  2. %FFPLOT Plots frequency functions
  3. %
  4. %    ffplot(G)  or  ffplot(G,SD)
  5. %
  6. %    The syntax is identical to that of BODEPLOT
  7. %    FFPLOT plots frequency functions with linear frequency scales
  8. %    and uses Hz as the frequency unit.
  9. %    BODEPLOT gives logarithmic frequency scales and uses rad/sec as the
  10. %    frequency unit. 
  11.  
  12. %    L. Ljung 10-4-90,2-10-92
  13. %    Copyright (c) 1990-92 by the MathWorks, Inc.
  14. %    All Rights Reserved.
  15.  
  16. if nargin<4 , mode=[];end
  17. if nargin<3, C=[];end
  18. if nargin<2, sd=[];end
  19. if isempty(mode),mode='sep';end
  20. if isempty(C),C='B';end
  21. if isempty(sd),sd=0;end
  22.  
  23. abp=['a';'A';'b';'B';'p';'P'];
  24. if sum(sd(1)==abp)>0, if length(C)>1,mode=C;end,C=sd;sd=0;end
  25. if length(sd)>1,mode=sd;sd=0;end
  26.  
  27. mode=mode(1:3);
  28. if mode=='SEP', mode='sep';end
  29. if mode=='SAM', mode='sam';end
  30. if mode~='sam', mode='sep';end
  31.  
  32. if C == 'a', C='A'; end
  33. if C == 'p', C='P'; end
  34. if C == 'b', C='B'; end
  35.  
  36. [m,n]=size(G);
  37. inputs1=G(1,:);mo=fix(inputs1/1000);mmo=max(mo);
  38. kko=[]; % The output indices
  39. for k=[0:mmo],if length(find(mo==k))>0,kko=[kko k];end,end
  40. G=G(2:m,:);
  41. for ko=kko+1
  42.  
  43. inputs=inputs1-(ko-1)*1000;
  44. mi=max(inputs(find(inputs<19)));
  45.  
  46. kki=[]; % The input indices
  47. for k=[1:mi 0], if length(find(inputs==k))>0,kki=[kki k];end,end
  48. if sum(kki)==0 & C=='B', C='A';end
  49. if mode=='sep'
  50.   for k=kki
  51.   if k==0 & C=='B',C='A';end
  52.   if C=='B',subplot(211),else subplot(111),end
  53.   if C=='A'| C=='B'
  54.  
  55.     semilogy(G(:,find(inputs==100+k))/2/pi,G(:,find(inputs==k)))
  56.     if sd>0,hold on,
  57.     ind=find(k+50==inputs);
  58.     semilogy(G(:,ind-2)/2/pi,G(:,ind-1)+sd*G(:,ind),'-.')
  59.     semilogy(G(:,ind-2)/2/pi,G(:,ind-1)-sd*G(:,ind),'-.') %Change here 2.04
  60.     hold off,end
  61.     xlabel('frequency (Hz)')
  62.  
  63.     if k~=0,title(['AMPLITUDE PLOT, input # ',int2str(k),' output # ',int2str(ko)])
  64.     else title(['SPECTRUM output # ',int2str(ko)]),end
  65.   end
  66.   if ((C=='B')|(C=='P'))&k~=0
  67.         if (C=='B'), subplot(212), end
  68.         if (C=='P'),subplot(111),end
  69.  
  70.     plot(G(:,find(inputs==100+k))/2/pi,G(:,find(inputs==20+k)))
  71.     if sd>0,hold on,
  72.     ind=find(k+70==inputs);
  73.     plot(G(:,ind-4)/2/pi,G(:,ind-1)+G(:,ind)*sd,'-.')
  74.     plot(G(:,ind-4)/2/pi,G(:,ind-1)-sd*G(:,ind),'-.') %Change here 2.04
  75.     hold off,end
  76.     title(['PHASE PLOT, input # ',int2str(k),' output # ',int2str(ko)])
  77.     xlabel('frequency (Hz)')
  78.     ylabel('phase')
  79.   end
  80.  
  81.  
  82.   if k~=kki(length(kki)),pause,end
  83. end
  84. end
  85. if mode=='sam' 
  86.  
  87.     if C=='B',subplot(211),else subplot(111),end
  88.       if C=='B' | C=='A'    
  89.     semilogy(G(:,find(inputs>99&inputs<120))/2/pi,G(:,find(inputs<20&inputs>-1)))
  90.     if sd>0,hold on,
  91.     ind=find(inputs<69 & inputs>49);
  92.     semilogy(G(:,ind-2)/2/pi,G(:,ind-1)+G(:,ind)*sd,'-.')
  93.     semilogy(G(:,ind-2)/2/pi,G(:,ind-1)-sd*G(:,ind),'-.'),hold off,end
  94.     xlabel('frequency (Hz)')
  95.     title(['AMPLITUDE PLOT output #',int2str(ko)])
  96.       end
  97.       if C=='B'| C=='P'
  98.          if C=='B',subplot(212),else subplot(111),end
  99.         plot(G(:,find(inputs>100&inputs<120))/2/pi,G(:,find(inputs<39 & inputs>19)))
  100.     if sd>0,hold on
  101.     ind=find(inputs<89 & inputs>69);
  102.     plot(G(:,ind-4)/2/pi,G(:,ind-1)+G(:,ind)*sd,'-.')
  103.     plot(G(:,ind-4)/2/pi,G(:,ind-1)-sd*G(:,ind),'-.'),hold off,end
  104.     xlabel('frequency (Hz)')
  105.     ylabel('phase')
  106.     title(['PHASE PLOT output #',int2str(ko)])
  107.       end
  108.     
  109. end,if ko~=kko(length(kko))+1,pause,end
  110.  
  111. end
  112.  
  113. hold off
  114. set(gcf,'NextPlot','replace');
  115.  
  116.