Example LPF Frequency Response Using

Figure 7.2 lists a short matlab program illustrating usage of
`freqz` in Octave (as found in the `octave-forge`
package). The same code should also run in Matlab, provided the
Signal Processing Toolbox is available. The lines of code not
pertaining to plots are the following:

[B,A] = ellip(4,1,20,0.5); % Design lowpass filter B(z)/A(z) [H,w] = freqz(B,A); % Compute frequency response H(w)The filter example is a recursive fourth-order elliptic function lowpass filter cutting off at half the Nyquist limit (`` '' in the fourth argument to

plot(w,abs(H)); plot(w,angle(H));However, the example of Fig.7.2 uses more detailed ``compatibility'' functions listed in Appendix J. In particular, the

[B,A] = ellip(4,1,20,0.5); % Design the lowpass filter [H,w] = freqz(B,A); % Compute its frequency response % Plot the frequency response H(w): % figure(1); freqplot(w,abs(H),'-k','Amplitude Response',... 'Frequency (rad/sample)', 'Gain'); saveplot('../eps/freqzdemo1.eps'); figure(2); freqplot(w,angle(H),'-k','Phase Response',... 'Frequency (rad/sample)', 'Phase (rad)'); saveplot('../eps/freqzdemo2.eps'); % Plot frequency response in a "multiplot" like Matlab uses: % figure(3); plotfr(H,w/(2*pi)); if exist('OCTAVE_VERSION') disp('Cannot save multiplots to disk in Octave') else saveplot('../eps/freqzdemo3.eps'); end |

Amplitude
Response
Phase Response |

[How to cite this work] [Order a printed hardcopy] [Comment on this page via email]

Copyright ©

Center for Computer Research in Music and Acoustics (CCRMA), Stanford University