Global Index (short | long) | Local contents | Local Index (short | long)
bodeplot(G,sd,C,mode)
BODEPLOT Plots the Bode diagram of a transfer function or spectrum. BODEPLOT(G) or BODEPLOT(G,SD) G is entered as the transfer function(s) or spectrum (spectra) of the standard frequency function format, produced by TH2FF, SPA or ETFE. See also FREQFUNC. Several plots in the same diagram are obtained by BODEPLOT([G1 G2 .. Gn]) The transfer functions Gk need not be given at the same frequencies. If SD is specified to a number larger than zero, also confidence intervals for the functions (corresponding to SD standard deviations) are shown as dash-dotted curves. The default mode is that amplitude and phase plots are shown simul- taneously, for each input (noise spectrum) present in G. For spectra the phase plots are omitted. ENTER will advance the plot from one input to the next (if any). To show amplitude or phase plots only use BODEPLOT(G,SD,'A') and BODEPLOT(G,SD,'P'), respectively. To ob- tain all plots in the same diagrams use BODEPLOT(G,SD,C,'same'). C is here 'A', 'P' or 'B' for amplitude, phase or both plots. (In these cases SD can be omitted for default) See also FFPLOT, NYQPLOT.
This function calls | This function is called by |
---|---|
function bodeplot(G,sd,C,mode) % L. Ljung 10-1-86, revised 7-7-87,10-2-92 % Copyright (c) 1986-98 by The MathWorks, Inc. % $Revision: 2.5 $ $Date: 1997/12/03 23:16:16 $ if nargin<1 disp('Usage: BODEPLOT(G)') disp(' BODEPLOT(G,SD,C,MODE)') return end if nargin<4 , mode=[];end if nargin<3, C=[];end if nargin<2, sd=[];end if isempty(mode),mode='sep';end if isempty(C),C='B';end if isempty(sd),sd=0;end abp=['a';'A';'b';'B';'p';'P']; if sum(sd(1)==abp)>0, if length(C)>1,mode=C;end,C=sd;sd=0;end if length(sd)>1,mode=sd;sd=0;end mode=mode(1:3); if mode=='SEP', mode='sep';end if mode=='SAM', mode='sam';end if mode~='sam', mode='sep';end if C == 'a', C='A'; end if C == 'p', C='P'; end if C == 'b', C='B'; end cols=get(gca,'colororder'); if sum(cols(1,:))>1.5 % Note colors start with the second color colord=['b','y','m','c','r','g']; % Dark background else colord=['k','b','g','r','c','m']; % Light background end [m,n]=size(G); inputs1=G(1,:);mo=fix(inputs1/1000);mmo=max(mo); kko=[]; % The output indices for k=[0:mmo],if length(find(mo==k))>0,kko=[kko k];end,end G=G(2:m,:); for ko=kko+1 inputs=inputs1-(ko-1)*1000; mi=max(inputs(find(inputs<19))); kki=[]; % The input indices for k=[1:mi 0], if length(find(inputs==k))>0,kki=[kki k];end,end if sum(kki)==0 & C=='B', C='A';end if mode=='sep' for k=kki if k==0 & C=='B',C='A';end newplot; if C=='B',subplot(211),else subplot(111),end if C=='A'| C=='B' indmod=find(inputs==100+k);ind2=find(inputs==k); for kk=1:length(indmod) col=colord(mod(kk,6)+1); semilogy(G(:,indmod(kk))/2/pi,G(:,ind2(kk)),col),hold on if sd>0 if length(inputs)>=indmod(kk)+2 if inputs(indmod(kk)+2)==k+50 semilogy(G(:,indmod(kk))/2/pi,G(:,indmod(kk)+1)+... sd*G(:,indmod(kk)+2),[col,'-.']) semilogy(G(:,indmod(kk))/2/pi,max(G(:,indmod(kk)+1)-... sd*G(:,indmod(kk)+2),0),[col,'-.']) else disp('No confidence info for this model.') end else disp('No confidence info for this model.') end end end hold off xlabel('frequency (Hz)') if k~=0,title(['AMPLITUDE PLOT, input # ',int2str(k),' output # ',int2str(ko)]) else title(['SPECTRUM output # ',int2str(ko)]),end end if ((C=='B')|(C=='P'))&k~=0 if (C=='B'), subplot(212), end if (C=='P'),newplot;subplot(111),end indmod=find(inputs==100+k);ind2=find(inputs==20+k); for kk=1:length(indmod) col=colord(mod(kk,6)+1); plot(G(:,indmod(kk))/2/pi,G(:,ind2(kk)),col),hold on if sd>0 if length(inputs)>=indmod(kk)+4 if inputs(indmod(kk)+4)==k+70 plot(G(:,indmod(kk))/2/pi,G(:,indmod(kk)+3)+... sd*G(:,indmod(kk)+4),[col,'-.']) plot(G(:,indmod(kk))/2/pi,G(:,indmod(kk)+3)-... sd*G(:,indmod(kk)+4),[col,'-.']) end end end end hold off title(['PHASE PLOT, input # ',int2str(k),' output # ',int2str(ko)]) xlabel('frequency (Hz)') ylabel('phase') end if k~=kki(length(kki)),pause,end end end if mode=='sam' if C=='B',subplot(211),else subplot(111),end if C=='B' | C=='A' semilogy(G(:,find(inputs>99&inputs<120))/2/pi,G(:,find(inputs<20&inputs>-1))) if sd>0,hold on, ind=find(inputs<69 & inputs>49); semilogy(G(:,ind-2)/2/pi,G(:,ind-1)+G(:,ind)*sd,'-.') semilogy(G(:,ind-2)/2/pi,max(G(:,ind-1)-sd*G(:,ind),0),'-.'),hold off,end xlabel('frequency (Hz)') title(['AMPLITUDE PLOT output #',int2str(ko)]) end if C=='B'| C=='P' if C=='B',subplot(212),else subplot(111),end plot(G(:,find(inputs>100&inputs<120))/2/pi,G(:,find(inputs<39 & inputs>19))) if sd>0,hold on ind=find(inputs<89 & inputs>69); plot(G(:,ind-4)/2/pi,G(:,ind-1)+G(:,ind)*sd,'-.') plot(G(:,ind-4)/2/pi,G(:,ind-1)-sd*G(:,ind),'-.'),hold off,end xlabel('frequency (Hz)') ylabel('phase') title(['PHASE PLOT output #',int2str(ko)]) end end,if ko~=kko(length(kko))+1,pause,end end hold off set(gca,'NextPlot','replace'); set(gcf,'NextPlot','replace');