Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Sponsor

Evaluate multicore with Texas Instruments:
Low-cost evaluation module & free software development kit available NOW.

Chapters

See Also

Embedded SystemsFPGAElectronics
Chapter Contents:

Search Introduction to Digital Filters

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Frequency Response Plot: swanalmainplot.m

Figure J.14 lists a Matlab script for plotting (in Fig.2.7) 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 and is compatible with Matlab only.

Figure J.14: 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(plotfile); % set by caller


Previous: Signal Plots: swanalplot.m
Next: Digital Filtering in Faust and PD

Order a Hardcopy of Introduction to Digital Filters


About the Author: Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )