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.
% 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'); |