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


Frequency Response Plot: swanalmainplot

Figure J.11 lists a matlab script for plotting (in Fig.2.6) the overlay of the theoretical frequency response with that measured using simulated sine-wave analysis for the case of the simplest lowpass filter. It is written to run in the specific context of the matlab script listed in Fig.2.3 of §2.2. This is not a general-purpose ``utility'' because it relies on global variables defined in the calling script. This script is included only for completeness.

Figure J.11: Matlab script for plotting overlay of theoretical frequency response with that measured using simulated sine-wave analysis.

 
% swanalmainplot.m
% Compare measured and theoretical frequency response.
% This script is invoked by swanalmainplot.m and family,
% and requires context set up by the caller.

figure(N+1); % figure number is arbitary

subplot(2,1,1);
ttl = 'Amplitude Response';
freqplot(f,gains,'*k',ttl,'Frequency (Hz)','Gain');
tar = 2*cos(pi*f/fs); % theoretical amplitude response
hold on; freqplot(f,tar,'-k'); hold off;
text(-0.08,mean(ylim),'(a)');

subplot(2,1,2);
ttl = 'Phase Response';
tpr = -pi*f/fs; % theoretical phase response
pscl = 1/(2*pi);% convert radian phase shift to cycles 
freqplot(f,tpr*pscl,'-k',ttl,'Frequency (cycles)',...
	'Phase shift (cycles)'); 
hold on; freqplot(f,phases*pscl,'*k'); hold off;
text(-0.08,mean(ylim),'(b)');
saveplot('./swanalmainplot.eps');


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 © 2024-09-03 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA