You are on page 1of 18

Session 1620

Use of MATLAB in Design and Analysis of Analog Bandpass


Filters to Meet Particular Specifications

Richard L. Martin
United States Naval Academy

I. Introduction

An alternative title for this paper might be “Bandpass Filter Design - Not as Simple As You
Thought - But Help is Not far Away”. One of the problems which has been noted with students
working on design projects involving the use of analog filters is an appreciation for the effects of
real filters. This is not meant as a knock against the present generation of students, but rather an
acknowledgment of the difficulties faced as design requirements force students to apply more
and more of those concepts which continue to crowd the various electrical engineering curricula.

In many instances, after basic first and second order analog filters are introduced, when signal
processing applications require filters, “ideal” filters are assumed. For bandpass filters, signals
within the pass band are assumed to pass through with constant gain while signals outside the
pass band are assumed to be totally rejected. The notion that “ideal” filters may be easily
implemented may also be reinforced as the students study the design of digital filters.

However, in our senior project design course and laboratory, real bandpass filters are frequently
required which have particular pass band characteristics and out-of-band rejection requirements.
Frequently a simple second order bandpass filter is implemented and expected to be “good
enough?” Then as the filter’s performance is found to be seriously lacking, and the reality sets in
of the difficulty encountered in meeting specifications for both pass band characteristics and out-
of-band rejection, enthusiasm for filter design quickly wanes. However, use of the various
functions and routines readily available and clearly presented in a student MATLAB text1 shows
that the design process is not as daunting as it might otherwise seem, and the drudgery associated
with rigorous filter design may be significantly reduced.

Contained in this paper is a procedure which begins with specifications for an analog filter which
appear at first glance to be easily attained. Then the reader is guided through the process of
designing the required filter starting with an intuitive “quick answer”. MATLAB’s frequency
response plot capabilities are used to show how the results of the “quick answer” fail to meet the
specs. Then the process moves on to a better, but still intuitive design, and finally to the
application of a design process which utilizes several of MATLAB’s functions.
Page 4.571.1
II. Problem Definition

Suppose we have received a desired AM double sideband signal with its carrier at 40 KHz and 20
Hz to 5 KHz bandlimited information. Also suppose there are similar but undesired AM-DSB
signals at the same amplitude with their carriers at 20 and 60 KHz.

The problem is to design a bandpass filter which will pass the 40KHz carrier and its sidebands
with no more than + 5 % variation across the pass band, and discriminate against the nearest
undesired sidebands (at 25 and 55 KHz) by 20 dB. A generic form of the required filter is shown
in Figure 1.

Gain (dB)
+5 %
0
-5%

-20

25 35 45 55 f (KHz)

Figure 1. Required Filter Characteristic.

III. Intuitive Design - Use of logspace, freqs, abs, log10, and semilogx

Since this seems like a simple enough filter to implement, let’s try a simple narrowband bandpass
filter having a second order denominator, with the form

Vo Ka ω r s
= . (1)
Vi s 2 + ω r s + ω 2
r
Q
Page 4.571.2
Noting that the + 5% variation in amplitude specified across the pass band is actually less than 1
dB, let’s choose a bandwidth wider than 10 KHz, but less than 15 KHz, being aware of the need
to reject frequencies just 15 KHz away from the 40 KHz center frequency. Therefore let us try a
center frequency of 40 KHz with a 3 dB bandwidth of 13 KHz, giving Q = 3.08. Also, we
choose Ka = 0.325, which will give 0 dB gain at the resonant frequency. MATLAB may be used
to quickly generate the frequency response plots (Gain and Phase) for this filter. The gain plot is
shown in Figure 2, along with the MATLAB program used. For simplicity, phase was not
included in the specifications and is not considered a factor here.

The user defined function dbsbp1 is made available to MATLAB by creating M-files dbsbp1.m
in the editor and calling that function from the command line. MATLAB functions logspace,
freqs, and abs are used to generate the data for the function semilogx which plots the gain as a
function of frequency in KHz. MATLAB would normally create the plot as a function of
frequency in radians/second. By entering the resonant frequency in the transfer function as 40,
rather than 40,000 times 2 pi, the x-axis is scaled to KHz. By redundantly defining the abscissa
values to be used in the transfer function calculations, an apparently smooth line may be drawn
through individually marked (with a + symbol), but less frequently calculated, data points.

A review of the gain plot of Figure 2 reveals that this attempt fails to meet the design goals on
several counts. Response to the following questions may be used to demonstrate the failings.

(1) What is the gain to the 40 KHz carrier?


A: 0 dB.

(2) What is the gain to a 20 Hz amplitude modulation signal whose carrier is 40 KHz?
A: 0 dB.

(3) What is the gain to a 5 KHz amplitude modulation signal whose carrier is 40 KHz?
A: Approximately - 2 dB, which is 2 dB down from (20 per cent lower than) the gain to
the 20 Hz signal. The gain varies too much across the pass band. The specification allows it to
be no more than 10 per cent down.

(4) What is the gain to the unwanted 5 KHz amplitude modulation signal whose carrier is 60
KHz?
A: -7.5 dB; or only 7.5 dB down from the carrier at 40 KHz. The specification calls for
the gain to be 20 dB down here.
Page 4.571.3
% Gain (dB) of Simple Bandpass Filter
% To run: "dbsbp1"
% "gtext ('dbsbp1')"
% "gtext ('Res freq = 40 KHz')"
% "gtext ('3 dB BW = 13 KHz -')"
% "gtext ('34 to 47 KHz')"
function db1 = dbsbp1(w)
a = [1 13 1600];
b = [13 0];
w1 = logspace(1,2, 26); w2 = logspace(1, 2, 200);
h1 = freqs(b, a, w1); h2 = freqs(b, a, w2);
mag1 = abs(h1); mag2 = abs(h2);
db1 = 20*log10(mag1); db2 = 20*log10(mag2);
semilogx(w2, db2, w1, db1, '+');
title ('Simple Bandpass Filter');
xlabel ('Frequency in KHz');
ylabel ('Gain in dB');
grid;

S im p le B a n d p a s s F ilt e r
0

dbs bp1

-5
R e s fre q = 4 0 K H z
3 dB B W = 13 K H z :
34 to 47 K H z
-1 0
G a in in d B

-1 5

-2 0

-2 5
1 2
10 10
F re q u e n c y in K H z

Figure 2. Gain of Simple Bandpass Filter


Page 4.571.4
IV. Cascading Filters - Use of conv and linspace

Therefore, our next try might be to cascade two simple bandpass filters with their center
frequencies offset from one another, providing a stagger tuned effect and having the form

Vo K1ω r 1s K 2ω r 2 s
= x . (2)
Vi s 2 + ω r 1 s + ω 2 s 2 + ω r 2 s + ω 2
r1 r2
Q1 Q2

This transfer function also describes two second order filters, one high pass and the other a low
pass. That is, an alternate implementation of the filter is allowed, although that will not be done
here.

Since our first try used a 13 KHz bandwidth centered around 40 KHz (extending from about 34
to 47 KHz, with a Q of approximately 3), let’s try center frequencies for our two filters at 37 and
43 KHz, each with Q of 5. The resulting transfer function, with numerator constants chosen at
1/Q, expecting to provide a center frequency gain of about 0 dB, is

Vo 37 s 43s
= x . (3)
Vi s 2 + 37 s + 37 2 s 2 + 43 s + 432
5 5
Again, MATLAB is used to generate the frequency response plots shown in Figures 3 and 4 for
this stagger tuned filter. In addition to use of the MATLAB functions used previously, the conv
function is used to multiply the two denominator polynomials. The function linspace is used to
provide a linear horizontal scale for a narrow range of frequencies around the filter’s center
frequency. The program lin2bp1 used to generate Figure 4 differs from that for Figure 3
(db2bp1) only in that pair of statements defining w1 and w2. The listing for Figure 4 is
provided to emphasize the ease with which the one basic M-file may be changed for another
filter.

The plots clearly show that this filter is better than the single bandpass filter. However, this
design still fails to meet the specifications. Although the gain at 25 KHz is down more than 20
dB from the gain at 40 KHz, the gain at 55 KHz is only down about 18 dB. Meanwhile, the gain
from 35 to 45 KHz varies about 5 dB, worse than we had before. But that’s not surprising since
we are using two narrow bandpass filters to obtain the out of band rejection, and if the stagger
tuning is not right on target, in-band frequencies will of course be affected.
Page 4.571.5
% Gain (dB) of 2 Cascaded Bandpass Filters
% To run: "db2bp1"
% "gtext ('db2bp1')"
% "gtext ('Res freqs = 37, 43 KHz')"
% "gtext ('3 dB BW = 13 KHz?')"
% "gtext ('34 to 47 KHz?')"
function db1 = db2bp1(w)
d1 = [1 7.4 1369]; d2 = [1 8.6 1849];
a = conv(d1,d2);
n1 = [7.4 0]; n2 = [8.6 0];
b = conv(n1, n2);
w1 = logspace(1, 2, 26); w2 = logspace(1, 2, 200);
h1 = freqs(b, a, w1); h2 = freqs(b, a, w2);
mag1 = abs(h1); mag2 = abs(h2);
db1 = 20*log10(mag1); db2 = 20*log10(mag2);
semilogx(w2, db2, w1, db1, '+');
title ('Gain of Two Cascaded Bandpass Filters');
xlabel ('Frequency in KHz');
ylabel ('Gain in dB');
grid;

G a in o f Tw o C a s c a d e d B a n d p a s s F ilt e rs
0

db2bp1

-1 0
R e s fre q s = 3 7 , 4 3 K H z
3 dB B w = 13 K Hz ?:
34 to 47 K H z ?
-2 0
G a in in d B

-3 0

-4 0

-5 0

-6 0
1 2
10 10
F re q u e n c y in K H z

Figure 3. Gain Plot of Two Cascaded Bandpass Filters


(Log Frequency Scale)
Page 4.571.6
% Gain (dB) of 2 Cascaded Bandpass Filters
% To run: "lin2bp1"
% "gtext ('lin2bp1')"
% "gtext ('Res freqs = 37, 43 KHz')"
% "gtext ('3 dB BW = 13 KHz? -')"
% "gtext ('34 to 47 KHz?')"
function db1 = lin2bp1(w)
d1 = [1 7.4 1369]; d2 = [1 8.6 1849];
a = conv(d1, d2);
n1 = [7.4 0]; n2 = [8.6 0];
b = conv(n1, n2);
w1 = linspace(30, 50, 21); w2 = linspace(30, 50, 200);
h1 = freqs(b, a, w1); h2 = freqs(b, a, w2);
mag1 = abs(h1); mag2 = abs(h2);
db1 = 20*log10(mag1); db2 = 20*log10(mag2);
plot(w2, db2, w1, db1, '+');
title ('Gain of Two Cascaded Bandpass Filters');
xlabel ('Frequency in KHz');
ylabel ('Gain in dB');
grid;

G a in o f Tw o C a s c a d e d B a n d p a s s F ilt e rs
-2

lin 2 b p 1
-4

-6

-8
G a in in d B

R e s fre q s = 3 7 , 4 3 K H z
-1 0
3 dB B w = 13 K Hz ?:
34 to 47 K H z ?
-1 2

-1 4

-1 6

-1 8

-2 0
30 32 34 36 38 40 42 44 46 48 50
F re q u e n c y in K H z

Figure 4. Gain Plot of Two Cascaded Bandpass Filters


(Linear Frequency Scale)
Page 4.571.7
V. Methodical Design - Use of cheb1ap, lp2bp, and phase

Therefore let us approach this filter design using a more methodical procedure. A little research
concerning bandpass filters reveals that Johnson2 not only provides some frequency response
plots of certain Butterworth and Chebyshev bandpass filters, but also provides a method for
converting low pass filters into bandpass filters. That technique for conversion of low pass filters
into bandpass filters, described later, is also accomplished by MATLAB.

Our design will begin with satisfying the pass band specification of + 5% variation across the
pass band extending from 35 to 45 KHz. If 40 KHz is taken as the center frequency, in order to
have the lower edge of the pass band at 35 KHz the upper edge has to be at 45.7 KHz, giving a
value of 3.7 for the filter’s Q.

It is noted that Butterworth bandpass filters are characterized by monotonic rolloff from the
center frequency with the gain down 3 dB from the maximum at the edges of the pass band.
Meanwhile Chebyshev bandpass filters exhibit ripple through the pass band with the gain at the
edge of the pass band down from the maximum gain equal to the amount of the ripple. Although
nothing was specified concerning the phase shift for the filter, the nature of the signal to be
filtered implies the desire for linear phase shift. Since Butterworth filters are considered to have
better linearity than Chebyshev filters in their phase characteristics, it is tempting to proceed with
the Butterworth form. However, relating the bandwidth of a Butterworth filter to our
specification of + 5% (0.8 dB) variation across the band is not easily done. Also, if we note that
some variation in our filter characteristic will occur due to component variation, we might want
to leave some safety margin. Therefore, we will proceed with the design assuming a Chebyshev
filter with 0.4 dB ripple.

The method for converting a low pass filter characteristic with corner frequency at fo into a
bandpass filter with resonant frequency at fo consists of replacing the LaPlace variable s in the
low pass characteristic by Q(s2+1)/s. MATLAB accomplishes that transformation with the
function lp2bp. Our next attempt at meeting the filter design specification therefore begins with
a second order Chebyshev low pass filter with 0.4 dB ripple and corner frequency at 40 KHz.
The MATLAB function cheb1ap(2, 0.4) yields poles at -0.7699 + 1.0454i and k = 1.6097. That
is, the normalized (to one radian/sec) second order low pass prototype for our filter is

1.6097
H LP2 ( s) = . (4)
s 2 + 15398
. s + 1.6848

Then s is replaced by Q(s2+1)/s (where Q = 3.7) by using the MATLAB function

[numt, dent] = lp2bp(num, den, Wo, BW),


where
num = [1.6097],
den = [1, 1.5398, 1.6848],
Wo = 1,
Page 4.571.8

and BW = 1/Q = 0.2703


The function returns

numt = [0, 0, 0.1176, 0, 0]


and dent = [1, 0.4162, 2.1231, 0.4162, 1],

which gives the normalized bandpass filter

0.1176s 2
H BPN 2 ( s) = 4 . (5)
s + 0.4162 s 3 + 2.1231s 2 + 0.4162 s + 1

Finally, the transfer function with center frequency at 40 KHz, which is used by MATLAB to
generate the frequency response plots of Figures 5 and 6, is

1881. s2
H BP 2 ( s) = 4 . (6)
s + 16.648s 3 + 3396.8s 2 + 26637 s + 2,560,000

The program db2ch041 used to generate Figure 5 is similar to that used to generate Figure 2
except for the labels and titles, and the statements defining the denominator and numerator are
now
a = [1 16.648 3396.96 26636.8 2560000]
and b = [188.1 0 0].

The program lin2ch041 used to generate Figure 6 differs from that used to generate Figure 3 in
the same manner.

Review of Figure 5 reveals that the rejection of a 55 KHz signal is only about 12 dB. However,
Figure 6 shows that the gain variation through the 35 to 45 KHz pass band is now restricted to
0.4 dB, well within our + 5% specification. In other words, we are on the right track.

Page 4.571.9
B P F i l t e r fr o m 2 n d O rd e r C h e b y s h e v w it h 0 . 4 d B R ip p le
0
db2ch041
-5

-1 0
R e s fr e q = 4 0 K H z
Q = 3 .7
-1 5
G a in in d B

-2 0

-2 5

-3 0

-3 5

-4 0

-4 5
1 2
10 10
F re q u e n c y in K H z

Figure 5. Gain Plot of 2nd Order Chebyshev Filter


(Log Frequency Scale)

B P F ilt e r fro m 2 n d O rd e r C h e b y s h e v w it h 0 . 4 d B R ip p le
2

lin 2 c h 0 4 1
0

-2

-4
G a in in d B

-6

-8

-1 0
R e s fre q = 4 0 K H z
Q = 3 .7
-1 2

-1 4
30 32 34 36 38 40 42 44 46 48 50
F re q u e n c y i n K H z

Figure 6. Gain Plot of 2nd Order Chebyshev Filter


Page 4.571.10

(Linear Frequency Scale)


Our next attempt at satisfying the overall filter design specification is to start with a third order
low pass Chebyshev filter with 0.4 dB ripple and corner frequency at 40 KHz. The MATLAB
function cheb1ap(3, 0.4) yields poles at -0.6708 and -0.3354 + 1.0428i with k = 0.8049. This
normalized third order low pass prototype is thus

1 0.8049
H LP3 ( s) = x 2 . (7)
( s + 0.6708) ( s + 0.6708s + 1.2)

Here, MATLAB function lp2bp is applied to each factor.

That is, first we use


num = [1.0], and den = [1, 0.6708],

and lp2bp results in


numt = [0, 0.2703, 0]
and dent = [1, 0.1813, 1].

Then we use
num = [0.8049], and den = [1, 0.6708, 1.2],
and lp2bp results in
numt = [0, 0, 0.0588, 0, 0]
and dent = [1, 0.1813, 2.0877, 0.1813, 1].

And now the normalized sixth order bandpass filter resulting from replacing s by 3.7(s2+1)/s is
therefore

0.2703s 0.0588s 2
H BPN 3 ( s) = 2 x , (8)
( s + 0.1813s + 1) ( s 4 + 0.1813s 3 + 2.0877 s 2 + 0.1813s + 1)

and the frequency response (gain and phase) plots, with center frequency at 40 KHz, are shown in
Figures 7, 8, and 9. Here again, the programs used to generate Figures 7 and 8 differ from those
used to generate Figures 5 and 6 (or Figures 2 and 3) in the statements defining d1, d2, n1, and
n2, which are conveniently provided in the listing accompanying Figure 9.

Figure 7 clearly shows the gains at 25 and 55 KHz are more than 20 dB below the gain at 40
KHz, and Figure 8 shows the gain across the 35 to 45 KHz pass band varies only 0.4 dB.
Meanwhile, the phase plot of Figure 9, which was developed by the use of MATLAB’s phase
function, is reasonably linear across the pass band.
Page 4.571.11
B P F i l t e r fr o m 3 r d O r d e r C h e b y s h e v w i t h 0 . 4 d B R i p p l e
0

db3ch041
-1 0

-2 0
R e s fr e q = 4 0 K H z
Q = 3 .7
-3 0
G a in in d B

-4 0

-5 0

-6 0

-7 0

-8 0
1 2
10 10
F re q u e n c y in K H z

Figure 7. Gain Plot of 3rd Order Chebyshev Filter


(Log Frequency Scale)

B P F i l t e r fr o m 3 r d O r d e r C h e b y s h e v w i t h 0 . 4 d B R i p p l e
2

lin 3 c h 0 4 1
0

-2

-4
G a in in d B

-6
R e s fr e q = 4 0 K H z
Q = 3 .7
-8

-1 0

-1 2

-1 4
30 32 34 36 38 40 42 44 46 48 50
F re q u e n c y in K H z

Figure 8. Gain Plot of 3rd Order Chebyshev Filter


Page 4.571.12

(Linear Frequency Scale)


% Phase (degrees) of Bandpass Filter
% from 3rd order Chebyshev with 0.4 dB ripple
% To run: "ph3ch041"
% "gtext ('ph3ch041')"
% "gtext ('Res freq = 40 KHz')"
% "gtext ('Q = 3.7')"
% "gtext ('+ calcd, o measd')"
function phase1 = ph3ch041(w)
d1 = [1 7.252 1600]; d2 = [1 7.252 3340.3 11603 2560000];
a = conv(d1, d2);
n1 = [10.81 0]; n2 = [94.08 0 0 ];
b = conv(n1, n2);
w1 = logspace(1, 2, 26); w2 = logspace(1, 2, 200);
h1 = freqs(b, a, w1); h2 = freqs(b, a, w2);
mag1 = abs(h1); mag2 = abs(h2);
phase1 = 57.3*angle(h1); phase2 = 57.3*angle(h2);
semilogx(w2, phase2, w1, phase1, '+');
title ('Phase of BP Filter from 3rd Order Chebyshev with 0.4 dB Ripple');
xlabel ('Frequency in KHz');
ylabel ('Phase in Degrees');
grid;

P h a s e o f B P F ilt e r fro m 3 rd O rd e r C h e b y s h e v w it h 0 . 4 d B R ip p le
200

ph3c h041
150

100
R e s fre q = 4 0 K H z
P h a s e in D e g re e s

Q = 3.7
50

-5 0

-1 0 0

-1 5 0

-2 0 0
1 2
10 10
F re q u e n c y in K H z
Page 4.571.13

Figure 9. Phase Plot of 3rd Order Chebyshev Filter


VI. Implementation - Use of roots and poly

One more area where MATLAB is useful is in the implementation of the filter function of
equation (8). Equation (8) may be considered to be a cascade of three bandpass filters, HBPNa(s),
HBPNb(s), and HBPNc(s). Although the first bandpass filter HBPNa(s), is evident in equation (8), the
other two result from the factoring of the 4th order denominator factor.

By applying MATLAB’s roots function to the 4th order denominator, two pairs of complex
conjugate roots result. Then application of MATLAB’s poly function to each pair of complex
conjugate roots provides the two second order denominator polynomials for the other two
bandpass filters. The numerator of the second term is factored in the same ratio as the
coefficients of the s term in the two resultant denominator quadratics. HBPN3(s) then becomes the
product of the three bandpass filter functions,

0.2703s
H BPNa ( s) = , (9)
s + 0.1813s + 1
2

0.28s
H BPNb ( s) = , (10)
s 2 + 0.1034 s + 1.3249

0.21s
and H BPNc ( s) = . (11)
s 2 + 0.078s + 0.7548

Each of these bandpass filters can be implemented by a circuit having the form of Figure 10.

Vi R C V
+ o

R C _
(K-1)R f

Rf

Figure 10. Op Amp Bandpass Filter


Page 4.571.14
Determination of the design equations for Figure 10 begins with the derivation of its transfer
function. This, unfortunately, is an area where MATLAB doesn’t help. But, this derivationis not
all that difficult. The transfer function for the circuit of Figure 10 is thus derived as follows.

The voltage at the op amp’s negative (-) input, and hence at its positive (+) input, is Vo/K.

Then, writing the node equations at Vx (the node to the right of Vi ) and at the (+) input gives:

Vi − Vx Vo − Vx V çæ äã
R
+
R
= Vx − o sC
K å â (12)

and
çæV − V äã sC = V + V sC
å K â KR K
o o o
x (13)

If equation (13) is solved for Vx, and is substituted into equation (12), the resultant can be solved
for the transfer function for the circuit as
çæ 1 äã
Vo
Ks
å RC â
=
ç 5 − K äã + 2
+ sæ
. (14)

å RC â 1 RC6
Vi 2
s 2

If equation (14) is then set equal to the standard form for a simple bandpass filter transfer
function of equation (1), we obtain
2
ωr = , (15)
RC

2 2
Q= , or K = 5− , (16)
5− K Q

K
and Ka = . (17)
2 Page 4.571.15
Since equations (9), (10), and (11) are normalized to ω r = 1 , implementation of the filter
involves denormalization by determining
f ra = 40 KHz for the first bandpass filter,
f rb = 40 KHz x 1.3249 for the second bandpass filter,
and f rc = 40 KHz x 0.7548 for the third bandpass filter.

Then for each stage, values for R, C, and Rf must be determined. Design involves choosing
values for C and Rf, and then determining values for R, K and (K-1)Rf. Table I summarizes the
resultant design values when C = 0.001 uF and Rf = 10 K are chosen.

Table I. Design Values for Filter Implementation

fr Q K R (K-1)Rf
(KHz) (KOhms) (KOhms)
1st stage 40.00 5.516 4.744 5.268 37.44
2nd stage 46.04 11.13 4.873 4.889 38.73
3rd stage 34.75 11.13 4.873 6.477 38.73

VII. Sensitivity - Repeated plots

Finally, MATLAB is useful for determining the sensitivity of the filter characteristic to
component variations without resorting to elegant means of analysis. Continue with our example
and assume that all of the components are implemented precisely according to the values
resulting from the design equations, giving the filter characteristics of Figures 7, 8, and 9.

Now allow the RC product in the implementation of the 3rd stage to increase 2 %. Although
equations (14) through (17) show that the only effect on the 3rd stage is to decrease the resonant
frequency by 2 %, the overall effect on the filter is not so clear. A repeat of the gain plot for
equation (8) incorporating the 2 % increase of the RC product in the 3rd stage results in Figure 11,
which can be compared to Figure 8. In addition to decreasing the lower corner of the bandpass
by 2 %, the overall gain of the filter is decreased approximately 10 %, with the gain increasing
across the pass band. Meanwhile, out of band response is not significantly affected.
Page 4.571.16
% Gain (dB) of Bandpass Filter
% from 3rd order Chebyshev with 0.4 dB ripple
% with +2 per cent increase in RC product of 3rd stage
% To run: "lin3ch042"
% "gtext ('lin3ch042')"
% "gtext ('Res freq = 40 KHz')"
% "gtext ('Q = 3.7')"
% "gtext ('+ calcd')"
function db1 = lin3ch042(w)
d1 = [1 7.252 1600];
d2 = [1 4.136 2119.8]; d3 = [1 3.0588 1160.8];
d4 = conv(d2,d3);
a = conv(d1, d4);
n1 = [10.81 0];
n2 = [11.2 0]; n3 = [8.2352 0];
n4 = conv(n2,n3);
b = conv(n1, n4);
w1 = linspace(30, 50, 21); w2 = linspace(30, 50, 200);
h1 = freqs(b, a, w1); h2 = freqs(b, a, w2);
mag1 = abs(h1); mag2 = abs(h2);
db1 = 20*log10(mag1); db2 = 20*log10(mag2);
plot(w2, db2, w1, db1, '+');
axis ([30 50 -14 2]);
title ('BP Filter with 2% Increase in 3rd Stage RC');
xlabel ('Frequency in KHz');
ylabel ('Gain in dB');
grid;

Figure 11. Gain Plot of 3rd Order Chebyshev Filter

B P F ilt e r w it h 2 % In c r e a s e i n 3 r d S t a g e R C
2

lin 3 c h 0 4 2
0

-2
G a in in d B

-4

-6

-8
R e s fr e q = 4 0 K H z
Q = 3 .7
-1 0

-1 2

-1 4
30 32 34 36 38 40 42 44 46 48 50
F re q u e n c y in K H z

Showing Sensitivity to Component Variation


Page 4.571.17
VIII. Summary

It has been shown here how MATLAB’s various capabilities, primarily those associated with its
frequency response plot (freqs) function, greatly enhances the design of analog bandpass filters.
A few tricks with plotting were demonstrated. First calculating and plotting the gain, with
symbols, for a limited number of abscissa values, and then calculating and plotting many more
points provides a smoother plot with highlighted “data” points. Plotting the data over a wide
frequency range using a log frequency scale (logspace) and then plotting over the pass band using
a linear frequency scale (linspace) allows closer inspection of the frequency response for
comparison with the specified response.

The conv function, applied to more complicated transfer functions having products of
polynomials, multiplies the polynomials and places them in the form ready for application of the
freqs function. MATLAB’s cheb1ap function was used to provide the poles and numerator
constants for the normalized Chebyshev low pass prototype filter which led to the bandpass filter
that met the filter specifications. MATLAB’s low pass to bandpass conversion function lp2bp
was used to accomplish the otherwise tedious and error-prone transformation of the low pass
filter to the bandpass filter with a specified Q.

Finally, MATLAB’s roots and poly functions were used to convert the resulting transfer
function’s 4th order denominator polynomials into their quadratic factors for implementation.
Then, further use of the freqs function was used to determine the sensitivity of the final design to
component variations.

References
1. The Student Edition of MATLAB, Prentice-Hall
2. D. E. Johnson, Introduction to Filter Theory; Chapter 3, Prentice-Hall.

Richard Martin
Richard L. Martin is a Professor of Electrical Engineering and Associate Chair of the Department
of Electrical Engineering at the United States Naval Academy. He teaches the EE majors’ senior
design course and laboratory sequence and coordinates the senior design projects. He received
his PhD from the University of Maryland, College Park, in 1968. Dr. Martin is a registered
Professional Engineer in the State of Maryland and has been actively involved in research with
the Naval Research Laboratory (Washington, D. C.) and the Naval Surface Warfare Center
(Annapolis).
Page 4.571.18

You might also like