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

Signal Plots: swanalplot.m

Figure J.10 lists a Matlab script for plotting input and output signals for the simplest lowpass filter in §2.2, used in Fig.[*] to produce Fig.2.4. 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.[*] 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.4.

 
%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();
  %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]  [Comment on this page via email]

``Introduction to Digital Filters with Audio Applications'', by Julius O. Smith III, (September 2007 Edition).
Copyright © 2018-04-13 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA