Frequency response of analog filters
freqs(___) with no output arguments plots the magnitude
and phase responses as functions of angular frequency in the current figure window. You can
use this syntax with either of the previous input syntaxes.
Frequency Response from Transfer Function
Find and graph the frequency response of the transfer function
a = [1 0.4 1]; b = [0.2 0.3 1]; w = logspace(-1,1); h = freqs(b,a,w); mag = abs(h); phase = angle(h); phasedeg = phase*180/pi; subplot(2,1,1) loglog(w,mag) grid on xlabel('Frequency (rad/s)') ylabel('Magnitude') subplot(2,1,2) semilogx(w,phasedeg) grid on xlabel('Frequency (rad/s)') ylabel('Phase (degrees)')
You can also generate the plots by calling
freqs with no output arguments.
Comparison of Analog IIR Lowpass Filters
Design a 5th-order analog Butterworth lowpass filter with a cutoff frequency of 2 GHz. Multiply by to convert the frequency to radians per second. Compute the frequency response of the filter at 4096 points.
n = 5; fc = 2e9; [zb,pb,kb] = butter(n,2*pi*fc,"s"); [bb,ab] = zp2tf(zb,pb,kb); [hb,wb] = freqs(bb,ab,4096);
Design a 5th-order Chebyshev Type I filter with the same edge frequency and 3 dB of passband ripple. Compute its frequency response.
[z1,p1,k1] = cheby1(n,3,2*pi*fc,"s"); [b1,a1] = zp2tf(z1,p1,k1); [h1,w1] = freqs(b1,a1,4096);
Design a 5th-order Chebyshev Type II filter with the same edge frequency and 30 dB of stopband attenuation. Compute its frequency response.
[z2,p2,k2] = cheby2(n,30,2*pi*fc,"s"); [b2,a2] = zp2tf(z2,p2,k2); [h2,w2] = freqs(b2,a2,4096);
Design a 5th-order elliptic filter with the same edge frequency, 3 dB of passband ripple, and 30 dB of stopband attenuation. Compute its frequency response.
[ze,pe,ke] = ellip(n,3,30,2*pi*fc,"s"); [be,ae] = zp2tf(ze,pe,ke); [he,we] = freqs(be,ae,4096);
Design a 5th-order Bessel filter with the same edge frequency. Compute its frequency response.
[zf,pf,kf] = besself(n,2*pi*fc); [bf,af] = zp2tf(zf,pf,kf); [hf,wf] = freqs(bf,af,4096);
Plot the attenuation in decibels. Express the frequency in gigahertz. Compare the filters.
plot([wb w1 w2 we wf]/(2e9*pi), ... mag2db(abs([hb h1 h2 he hf]))) axis([0 5 -45 5]) grid xlabel("Frequency (GHz)") ylabel("Attenuation (dB)") legend(["butter" "cheby1" "cheby2" "ellip" "besself"])
The Butterworth and Chebyshev Type II filters have flat passbands and wide transition bands. The Chebyshev Type I and elliptic filters roll off faster but have passband ripple. The frequency input to the Chebyshev Type II design function sets the beginning of the stopband rather than the end of the passband. The Bessel filter has approximately constant group delay along the passband.
Frequency Response of a Lowpass Analog Bessel Filter
Design a 5th-order analog lowpass Bessel filter with an approximately constant group delay up to rad/s. Plot the frequency response of the filter using
[b,a] = besself(5,10000); % Bessel analog filter design freqs(b,a) % Plot frequency response
a — Transfer function coefficients
Transfer function coefficients, specified as vectors.
[b,a] = butter(5,50,'s') specifies a fifth-order
Butterworth filter with a cutoff frequency of 50 rad/second.
w — Angular frequencies
positive real vector
Angular frequencies, specified as a positive real vector expressed in rad/second.
2*pi*logspace(6,9) specifies 50 logarithmically spaced
angular frequencies from 1 MHz (2π × 106 rad/second) and 1 GHz (2π × 109 rad/second).
n — Number of evaluation points
200 (default) | positive integer scalar
Number of evaluation points, specified as a positive integer scalar.
h — Frequency response
Frequency response, returned as a vector.
wout — Angular frequencies
Angular frequencies at which
h is computed, returned as a
freqs returns the complex frequency response of an analog filter
a. The function evaluates the
ratio of Laplace transform polynomials
along the imaginary axis at the frequency points s = jω:
s = 1j*w; h = polyval(b,s)./polyval(a,s);
Introduced before R2006a