This module is part of the collection, A First Course in Electrical and Computer Engineering. The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.
When we design a filter, we design it for a purpose. For example, a
moving average filter is often designed to pass relatively constant data while
averaging out relatively variable data. In an effort to clarify the behavior of
a filter, we typically analyze its response to a standard set of test signals. We
will call the impulse, the step, and the complex exponential the standard test
signals.
Unit Pulse Sequence. The unit pulse sequence is the sequence
u
n
=
δ
n
=
1
,
n
=
0
0
,
n
≠
0
.
u
n
=
δ
n
=
1
,
n
=
0
0
,
n
≠
0
.
(1)
This sequence, illustrated in Figure 1, consists of all zeros except for a
single one at n=0n=0. If the unit pulse sequence is passed through a moving
average filter (whether finite or not), then the output is called the unit pulse response:
h
n
=
∑
k
=
0
∞
w
k
δ
n
-
k
=
w
n
.
h
n
=
∑
k
=
0
∞
w
k
δ
n
-
k
=
w
n
.
(2)
(Note that δn-k=0δn-k=0 unless n=k.n=k.) So the unit pulse sequence may be used to read out the weights of a moving average filter. It is common practice to use
w
k
w
k
(the kthkth weight) and
h
k
h
k
(the kthkth impulse response) interchangeably.
Find the unit pulse response for the finite moving average xn=∑k=0N-1wkun-kxn=∑k=0N-1wkun-k. Caution: You must consider n<0,0≤n≤N-1n<0,0≤n≤N-1, and n≥Nn≥N.
Find the unit pulse response for the recursive filter xn=axn-1+w0unxn=axn-1+w0un.
Unit Step Sequence. The unit step sequence is the sequence
u
n
=
ξ
n
=
1
,
n
≥
0
0
,
n
<
0
.
u
n
=
ξ
n
=
1
,
n
≥
0
0
,
n
<
0
.
(3)
This sequence is illustrated in Figure 2. When this sequence is applied to a moving average filter, the result is the unit step response
g
n
=
∑
k
=
0
n
w
k
=
∑
k
=
0
n
h
k
.
g
n
=
∑
k
=
0
n
w
k
=
∑
k
=
0
n
h
k
.
(4)
The unit step response is just the sequence of partial sums of the unit pulse response.
Find the unit step response for the finite moving average filter xn=∑k=0N-1wkun-kxn=∑k=0N-1wkun-k. Specialize your general result to the special case where wk=1Nwk=1N for k=0,1,...,N-1k=0,1,...,N-1.
Find the unit step response for the recursive filter xn=axn-1+w0unxn=axn-1+w0un.
Complex Exponential Sequence. The complex exponential sequence is the sequence
u
k
=
e
j
k
θ
,
k
=
0
,
±
1
,
±
2
,
...
u
k
=
e
j
k
θ
,
k
=
0
,
±
1
,
±
2
,
...
(5)
This sequence, illustrated in Figure 3, is a “discrete-time phasor” that
“ratchets” counterclockwise (CCW) as
k
k moves to k+1k+1 and clockwise (CW)
as
k
k moves to k-1k-1. Each time the phasor ratchets, it turns out an angle
of
θ
θ. Why should such a sequence be a useful test sequence? There are two
reasons.
(i)
e
j
k
θ
e
j
k
θ
represents (or codes) coskθcoskθ. The real part of the sequence ejkθejkθ is the cosinusoidal sequence coskθcoskθ:
Re [ejkθ]=coskθ. Re [ejkθ]=coskθ.
(6)Therefore the discrete-time phasor ejkθejkθ represents (or codes) coskθcoskθ in the
same way that the continuous-time phasor ejωtejωt codes cosωtcosωt. If the moving
average filter
x
n
=
∑
k
=
0
∞
h
k
u
n
-
k
x
n
=
∑
k
=
0
∞
h
k
u
n
-
k
(7)has real coefficients, we can get the response to a cosinusoidal sequence by
taking the real part of the following sum:
x
n
=
∑
k
=
0
∞
h
k
cos
(
n
-
k
)
θ
=
Re
[
∑
k
=
0
∞
h
k
e
j
(
n
-
k
)
θ
]
=
Re
[
e
j
n
θ
∑
k
=
0
∞
h
k
e
-
j
k
θ
]
.
x
n
=
∑
k
=
0
∞
h
k
cos
(
n
-
k
)
θ
=
Re
[
∑
k
=
0
∞
h
k
e
j
(
n
-
k
)
θ
]
=
Re
[
e
j
n
θ
∑
k
=
0
∞
h
k
e
-
j
k
θ
]
.
(8)
In this formula, the sum
∑k=0∞hke-jkθ∑k=0∞hke-jkθ
(9)is called the complex frequency response of the filter and is given the symbol
H(ejθ)=∑k=0∞hke-jkθ.H(ejθ)=∑k=0∞hke-jkθ.
(10)This complex frequency response is just a complex number, with a magnitude
|H(ejθ)||H(ejθ)| and a phase arg H(ejθ)H(ejθ). Therefore the output of the moving average
filter is
x
n
=
Re
[
e
j
n
θ
H
(
e
j
θ
)
]
=
Re
[
e
j
n
θ
|
H
(
e
j
θ
)
|
e
j
arg
H
(
e
j
θ
)
]
=
|
H
(
e
j
θ
)
|
c
o
s
[
n
θ
+
arg
H
(
e
j
θ
)
]
.
x
n
=
Re
[
e
j
n
θ
H
(
e
j
θ
)
]
=
Re
[
e
j
n
θ
|
H
(
e
j
θ
)
|
e
j
arg
H
(
e
j
θ
)
]
=
|
H
(
e
j
θ
)
|
c
o
s
[
n
θ
+
arg
H
(
e
j
θ
)
]
.
(11)
This remarkable result says that the output is also cosinusoidal, but its amplitude is |H(ejθ)||H(ejθ)| rather than 1, and its phase is argH(ejθ)argH(ejθ) rather than 0. In the examples to follow, we will show that the complex “gain” H(ejθ)H(ejθ) can be highly selective in
θ
θ, meaning that cosines of some angular frequencies are passed with little attenuation while cosines of other frequencies are dramatically attenuated. By choosing the filter coefficients, we can design the frequency selectivity we would like to have.
(ii) ejkθejkθ is a sampled data version of
e
jωt
e
jωt. The discrete-time phasor ejkθejkθ can be produced physically by sampling the continuous-time phasor
ejωtejωt at the periodic sampling instants tk=kTtk=kT:
e
j
k
θ
=
e
j
ω
t
|
t
=
k
T
=
e
j
ω
k
T
θ
=
ω
T
.
e
j
k
θ
=
e
j
ω
t
|
t
=
k
T
=
e
j
ω
k
T
θ
=
ω
T
.
(12)
The dimensions of
θ
θ are radians, the dimensions of
ω
ω are radians/second, and
the dimensions of
T
T are seconds. We call
TT the sampling interval and 1T1T the
sampling rate or sampling frequency. If the original angular frequency of the
phasor ejωtejωt is increased to ω+m(2πT)ω+m(2πT), then the discrete-time phasor remains
ejkθejkθ :
ej[ω+m(2π/T)]t|t=kT=ej(ωkT+km2π)=ejkθ.ej[ω+m(2π/T)]t|t=kT=ej(ωkT+km2π)=ejkθ.
(13)This means that all continuous-time phasors of the form ej[ω+m(2π/T)]tej[ω+m(2π/T)]t “hide
under the same alias” when viewed through the sampling operation. That
is, the sampled-data phasor cannot distinguish the frequency ωω from the frequency ω+m2πTω+m2πT. In your subsequent courses you will study aliasing in more
detail and study the Nyquist rule for sampling:
T≤2πΩ;1T≥Ω2πT≤2πΩ;1T≥Ω2π
(14)This rule says that you must sample signals at a rate (1T)(1T) that exceeds the
bandwidth
Ω2πΩ2π of the signal.
Let's pass the cosinusoidal sequence uk=uk= cos kθkθ through the finite moving average filter
x
n
=
∑
k
=
0
N
-
1
h
k
u
n
-
k
h
k
=
1
N
k
=
0
,
1
,
...
,
N
-
1
.
x
n
=
∑
k
=
0
N
-
1
h
k
u
n
-
k
h
k
=
1
N
k
=
0
,
1
,
...
,
N
-
1
.
(15)We know from our previous result that the output is
xn=|H(ejθ)|cos[nθ+argH(ejθ)].xn=|H(ejθ)|cos[nθ+argH(ejθ)].
(16)The complex frequency response for this example is
H
(
e
j
θ
)
=
∑
k
=
0
N
-
1
1
N
e
-
j
k
θ
=
1
N
1
-
e
-
j
N
θ
1
-
e
-
j
θ
H
(
e
j
θ
)
=
∑
k
=
0
N
-
1
1
N
e
-
j
k
θ
=
1
N
1
-
e
-
j
N
θ
1
-
e
-
j
θ
(17)(Do you see your old friend, the finite sum formula, at work?) Let's try to
manipulate the result into a more elegant form:
H
(
e
j
θ
)
=
1
N
e
-
j
(
N
/
2
)
θ
[
e
j
(
N
/
2
)
θ
-
e
-
j
(
N
/
2
)
θ
]
e
-
j
(
θ
/
2
)
[
e
j
(
θ
/
2
)
-
e
-
j
(
θ
/
2
)
]
=
1
N
e
-
j
[
(
N
-
1
)
/
2
]
θ
sin
(
N
2
θ
)
sin
(
1
2
θ
)
.
H
(
e
j
θ
)
=
1
N
e
-
j
(
N
/
2
)
θ
[
e
j
(
N
/
2
)
θ
-
e
-
j
(
N
/
2
)
θ
]
e
-
j
(
θ
/
2
)
[
e
j
(
θ
/
2
)
-
e
-
j
(
θ
/
2
)
]
=
1
N
e
-
j
[
(
N
-
1
)
/
2
]
θ
sin
(
N
2
θ
)
sin
(
1
2
θ
)
.
(18)The magnitude of the function H(ejθ)H(ejθ) is
|H(ejθ)|=1N,|sin(N2θ)sin(12θ)|.|H(ejθ)|=1N,|sin(N2θ)sin(12θ)|.
(19)At θ=0θ=0, corresponding to a “DC phasor,” H(ejθ)H(ejθ) equals 1; at θ=2πNθ=2πN|H(ejθ)=0||H(ejθ)=0|. The magnitude of the complex frequency response is plotted in
Figure 4.
This result shows that the moving average filter is frequency selective, passing
low frequencies with gain near 1 and high frequencies with gain near 0.
Compute the phase of the complex frequency response
H
(
e
j
θ
)
=
1
N
e
-
j
[
(
N
-
1
)
/
2
]
θ
sin
(
N
2
θ
)
sin
(
1
2
θ
)
.
H
(
e
j
θ
)
=
1
N
e
-
j
[
(
N
-
1
)
/
2
]
θ
sin
(
N
2
θ
)
sin
(
1
2
θ
)
.
(20)
Choose the filter length
N
N for the filter hk=1N,k=0,1,...,N-1hk=1N,k=0,1,...,N-1, so that a 60 Hz cosine, sampled at the rate 1T=1801T=180, is perfectly zeroed
out as it comes through the filter.
(MATLAB) Write a MATLAB program to compute and plot
the magnitude |H(ejθ)||H(ejθ)| and the phase arg H(ejθ)H(ejθ) versus -π<θ<π-π<θ<π when
H
(
e
j
θ
)
=
1
N
e
-
j
[
(
N
-
1
)
/
2
]
θ
sin
(
N
2
θ
)
sin
(
1
2
θ
)
.
H
(
e
j
θ
)
=
1
N
e
-
j
[
(
N
-
1
)
/
2
]
θ
sin
(
N
2
θ
)
sin
(
1
2
θ
)
.
(21)
Choose suitable increments for
θ
θ.
Compute the complex frequency response H(ejθ)H(ejθ) for the recursive filter xn=axn-1+w0unxn=axn-1+w0un.
"Reviewer's Comments: 'I recommend this book as a "required primary textbook." This text attempts to lower the barriers for students that take courses such as Principles of Electrical Engineering, […]"