Signal Plots: swanalplot.m Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Signal Plots: swanalplot.m

Figure H.13 lists a Matlab script for plotting input and output signals for the simplest lowpass filter in §2.2, used in Fig.2.4 to produce Fig.2.5. This is not really a ``utility'' since it relies on global variables. It is instead a script containing mundane plotting code that was omitted from Fig.2.4 to make it fit on one page. I include it only because people keep asking for it! The script is compatible with Matlab only.

Figure: Matlab script for plotting input/output signals in Fig.2.5.

 
%swanalplot.m - plots needed by swanal.m

doplots = 1; % set to 0 to skip plots
dopause = 0; % set to 1 to pause after each plot
if doplots
  figure(gcf);
  subplot(2,1,1);
  ttl=sprintf('Filter Input Sinusoid, f(%d)=%0.2f',k,f(k));
  timeplot(t,s,'*k',ttl);
  tinterp=0:(t(2)-t(1))/10:t(end); % interpolated time axis
  si = ampin*cos(2*pi*f(k)*tinterp+phasein); % for plot
  text(-1.5,0,'(a)');
  hold on; plot(tinterp,si,'--k'); hold off;
  subplot(2,1,2);
  ttl='Filter Output Sinusoid';
  timeplot(t,y,'*k',ttl);
  text(-1.5,0,'(b)');
  if dopause, disp('PAUSING - [RETURN] to continue . . .'); 
  pause; end
  saveplot(sprintf('../eps/swanal-%d.eps',k));
end


Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work] [Order a printed hardcopy]

``Introduction to Digital Filters with Audio Applications'', by Julius O. Smith III, (August 2006 Edition).
Copyright © 2007-02-02 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA  [Automatic-links disclaimer]