Professional Documents
Culture Documents
Chapter 8
8.1 Problems
Problem 8.1 (MA digital filter from description) Write the difference equation and draw the block
diagram of the digital filter that computes the average of the current and past two samples of input
sequence xi .
(ans: Difference equation:
xi + xi−1 +
yi =
xi−2
Block diagram: 3
X + 1/3 y
i i
Problem 8.2 (Difference equation from MA digital filter structure) Write the difference equation of
the digital filter shown in Figure 8.1.
(ans:
yi = xi + 3xi−1 + 2xi−2 + xi−3
)
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Problem 8.3 (AR digital filter from description) Write the difference equation and draw the block
diagram of the digital filter whose current output is the sum of twice the current input and half the
previous output.
(ans: Difference equation:
yi = 0.5yi−1 + 2xi
87
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
88 CHAPTER 8. DIGITAL SIGNAL PROCESSING
xi yi
δ
3
δ
2
Block diagram:
X 2 + y
i i
1/2
Problem 8.4 (First-order AR digital filter with positive feedback coefficient) Draw the digital filter
structure and compute the unit-sample response hi for 0 ≤ i ≤ 3 of the digital filter defined by the
difference equation
yi = 0.9yi−1 + xi
What value of i produces hi < 0.01?
X + y
i i
0.9
The unit-sample response hi equals yi when xi = di and assuming zero initial conditions (hi = 0 for
i < 0).
i=0
=0 =1
z}|{ z}|{
h0 = 0.9 h −1 + d 0 = 1
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.1. PROBLEMS 89
i=1
=1 =0
z}|{ z}|{
h1 = 0.9 h 0 + d 1 = 0.9
i=2
=0.9 =0
z}|{ z}|{
h2 = 0.9 h 1 + d 2 = 0.81
i=3
=0.81 =0
z}|{ z}|{
h3 = 0.9 h 2 + d 3 = 0.729
In general, hi = 0.9i . Solving for i gives
log(hi )
i=
log(0.9)
log10 (0.01) −2
imin > = = 43.7
log10 (0.9) −0.0458
Hence, imin = 44.
)
Problem 8.5 (Difference equation from AR filter structure) Write the difference equation of the dig-
ital filter shown in Figure 8.2.
xi yi
δ
1.5
δ
-0.4
δ
-0.3
(ans:
yi = 1.5yi−1 − 0.4yi−2 − 0.3yi−3
)
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
90 CHAPTER 8. DIGITAL SIGNAL PROCESSING
Problem 8.6 (Second-order AR system) Assuming zero initial conditions, compute the unit-sample
response hi for 0 ≤ i ≤ 2 for the difference equation
yi = 2r cos(ωo )yi−1 − r 2 yi−2 + xi
yi = ai yi−1 + a2 yi−2 + xi
where
a1 = 2r cos(ωo ) = 2(0.9) cos(π/10) = 1.712
a2 = −r2 = −0.81
gives
yi = 1.712yi−1 − 0.81yi−2 + xi
The unit-sample response hi equals yi when xi = di and assuming zero initial conditions (hi = 0 for
i < 0).
i=0
=0 =0 =1
z}|{ z}|{ z}|{
h0 = 1.712 h −1 −0.81 h −2 + d 0 = 1
i=1
=1 =0 =0
z}|{ z}|{ z}|{
h1 = 1.712 h 0 −0.81 h −1 + d 1 = 1.712
i=2
=1.712 =1 =0
Problem 8.7 (ARMA filter from difference equation) Draw two ARMA digital filters that correspond
to the difference equation
yi = 2r cos(ωo )yi−1 − r 2 yi−2 + xi − r cos(ωo )xi−1
for r = 0.9 and ωo = π/10. The first structure is configured as an initial MA filter that connects to an
AR filter. The second structure is configured as an initial AR filter that connects to an MA filter.
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.1. PROBLEMS 91
where
a1 = 2r cos(ωo ) = 2(0.9) cos(π/10) = 1.712
a2 = −r2 = −0.81
b0 = 1
b1 = −r cos(ωo ) = −0.9 cos(π/10) = −0.856
gives
yi = 1.712yi−1 − 0.81yi−2 + xi − 0.856xi−1
The direct and efficient block diagrams of the ARMA filter with MA followed by AR:
X
i + + y
i
δ δ
−0.856 1.712
−0.81
X
i + y
i
δ δ
−0.856 1.712
−0.81
The direct and efficient block diagrams of the ARMA filter with AR followed by MA:
X
i + + y
i
δ δ
1.712 −0.856
−0.81
X
i + +
y
i
δ
1.712 −0.856
−0.81
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
92 CHAPTER 8. DIGITAL SIGNAL PROCESSING
Problem 8.8 (ARMA filter from difference equation) Draw two ARMA digital filters that correspond
to the difference equation
for r = 0.9 and ωo = π/10. The first structure is configured as an initial MA filter that connects to an
AR filter. The second structure is configured as an initial AR filter that connects to an MA filter.
(ans: Simplify the difference equation by computing the coefficient values, as
where
a2 = −1
b0 = 0
X
i + y
i
δ δ
−0.309 1.712
−1
The direct and efficient block diagrams of the ARMA filter with AR followed by MA:
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.1. PROBLEMS 93
X
i +
δ δ
y
1.712 −0.309
i
−1
X
i +
δ
1.712 −0.309
i
−1
Problem 8.9 (Difference equation from ARMA filter block diagram) Write the difference equation
of the digital filter shown in Figure 8.3.
xi yi
δ δ
1.2
δ δ
-0.5
(ans:
yi = 1.2yi−1 − 0.5yi−2 + xi−2
)
Problem 8.10 (Difference equation from efficient ARMA filter block diagram) Write the difference
equation of the digital filter shown in Figure 8.4.
(ans:
yi = 1.2yi−1 − 0.5yi−2 + xi + 1.2xi−1 − 0.5xi−2
)
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
94 CHAPTER 8. DIGITAL SIGNAL PROCESSING
xi yi
δ
1.2 1.2
δ
-0.5 -0.5
Problem 8.11 (Verification of cosine sequence generator) Verify Example ?? that the difference equa-
tion
yi = 2 cos(ωo )yi−1 − yi−2 + xi − cos(ωo )xi−1
has unit-sample response
hi = cos(ωo i) for 0 ≤ i ≤ 2
for ωo = π/8. Assume zero initial conditions and compare hi with cos(ωo i) for 0 ≤ i ≤ 2.
(ans: Simplify the difference equation by computing the coefficient values, as
yi = ai yi−1 + a2 yi−2 + xi
where
a1 = 2 cos(π/8) = 1.848
a2 = −1
b0 = 1
b1 = − cos(π/8) = −0.924
gives
yi = 1.848yi−1 − yi−2 + xi − 0.924xi−1
The unit-sample response hi equals yi when xi = di and assuming zero initial conditions (hi = 0 for
i < 0).
i=0
=0 =0 =1 =0
z}|{ z}|{ z}|{ z}|{
h0 = 1.848 h −1 − h −2 + d 0 −0.924 d −1 = 1
Verification:
cos(0) = 1
i=1
=1 =0 =0 =1
z}|{ z}|{ z}|{ z}|{
h1 = 1.848 h 0 − h −1 + d 1 −0.924 d 0 = 0.924
Verification:
cos(π/8) = 0.924
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.1. PROBLEMS 95
i=2
=0.924 =1 =0 =0
z}|{ z}|{ z}|{ z}|{
h2 = 1.848 h 1 − h 0 + d 2 −0.924 d 1 = 0.708
Verification: n
Problem 8.12 (Sine sequence generator) Verify that the difference equation
yi = ai yi−1 + a2 yi−2 + xi
where
a1 = 2 cos(π/8) = 1.848
a2 = −1
b0 = 0
b1 = sin(π/8) = 0.383
gives
yi = 1.848yi−1 − yi−2 + +0.383xi−1
The unit-sample response hi equals yi when xi = di and assuming zero initial conditions (hi = 0 for
i < 0).
i=0
=0 =0 =0
z}|{ z}|{ z}|{
h0 = 1.848 h −1 − h −2 +0.383 d −1 = 0
Verification:
sin(0) = 0
i=1
=0 =0 =1
z}|{ z}|{ z}|{
h1 = 1.848 h 0 − h −1 +0.383 d 0 = 0.383
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
96 CHAPTER 8. DIGITAL SIGNAL PROCESSING
Verification:
sin(π/8) = 0.383
i=2
=0.383 =0 =0
z}|{ z}|{ z}|{
h2 = 1.848 h 1 − h 0 +0.383 d 1 = 0.708
Verification:
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.2. MATLAB PROJECTS 97
0.5
i
x
0
0 1 2 3 4 5 6 7 8 9
i
coefficient sequence
0.2
0.15
0.1
i
h
0.05
0
0 0.5 1 1.5 2 2.5 3 3.5 4
i
ten samples of unit−sample response
0.2
0.15
0.1
i
y
0.05
0
0 1 2 3 4 5 6 7 8 9
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
98 CHAPTER 8. DIGITAL SIGNAL PROCESSING
Project 8.2 (MA filter implementing a linear interpolation) The unit-sample response of a three-sample
MA digital filter that acts as linear interpolator is given by
input sequence
1
0.5
0
i
x
−0.5
−1
0 10 20 30 40 50 60 70
i
output sequence
1
0.5
0
i
y
−0.5
−1
0 10 20 30 40 50 60 70
i
error sequence
0.1
0.05
0
εi
−0.05
−0.1
0 10 20 30 40 50 60 70
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.2. MATLAB PROJECTS 99
Project 8.3 (MA matched filter) Using Example 16.39 as a guide, compose a Matlab script to com-
pute the output of a MA filter whose filter coefficient sequence hi equals the input sequence xi in time-
reversed order. For example, if x0 = 1, x1 = 2, and x2 = 3, then h0 = 3, h1 = 2, and h2 = 1. Such
a filter is called a matched filter. The output sequence of a matched filter is symmetric about the time
point at which the entire signal sequence is in the MA filter (about i = 2).
Demonstrate this matched filter operation by specifying your favorite set of five values - not all equal
and some less than zero - for hi for 0 ≤ i ≤ 4 and compute the output. The matched filter is the basis
for the matched processor for detecting data signals in the presence of noise, described in Chapter 10.
(ans:
x = 1:5; % define signal sequence
h = 5:-1:1;
ny = length(x) + length(h) - 1; % define matched filter coef sequence
xp= [x zeros(1,length(h)-1)]; % define signal sequence for plotting
hp= [h zeros(1,length(x)-1)]; % define matched filter coef sequence for plotting
i = 0:length(hp)-1;
subplot(3,1,1),stem(i,xp)
title(’input sequence’); xlabel(’i’); ylabel(’x_i’)
subplot(3,1,2),stem(i,hp)
title(’matched-filter corefficient sequence’); xlabel(’i’); ylabel(’h_i’)
y = f_MA_filter(x,h); % filter
subplot(3,1,3),stem(i,y)
title(’output sequence’); xlabel(’i’); ylabel(’y_i’)
input sequence
6
4
xi
0
0 1 2 3 4 5 6 7 8
i
matched−filter corefficeint
sequence
6
4
hi
0
0 1 2 3 4 5 6 7 8
i
output
sequence
60
40
yi
20
0
0 1 2 3 4 5 6 7 8
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
100 CHAPTER 8. DIGITAL SIGNAL PROCESSING
Project 8.4 (Cascading MA filters) Compose a Matlab script that cascades two MA filters with the
output of the first forming the input to the second. Verify your program by computing the unit-sample
response of the cascaded connection of two identical three-sample linear interpolators.
(ans: The output of the second MA filter is the convolution of the interpolation filter unit-sample re-
sponse convolved with itself.
unit−sample
sequence
1
0.5
xi
0
0 1 2 3 4 5 6 7 8 9
i
first MA filter output
sequence
1
y1i
0.5
0
0 2 4 6 8 10
12 i
second MA filter output
1.5 sequence
1
y2i
0.5
0
0 2 4 6 8 10 12
14
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.2. MATLAB PROJECTS 101
Project 8.5 (AR digital filter) Using Example 16.40 as a guide, compose a Matlab script to implement
a general AR digital filter. Verify your program by computing hi for 0 ≤ i ≤ 50 for the first-order AR
filters following coefficients.
1. a = −0.9
2. a = 1
3. a = 1.1
4. a = 10
(ans: This problem displays four plots per figure and uses axis command. The solution for the problem
when all y values are equal is given.
AR function:
function y = f_AR_filter(x,a,ny)
nx = length(x);
mem = zeros(size(a)); % assign and initialize memory array
nm = length(mem); % memory size
y = zeros(1,ny); % assign output array
for i = 1:nx
y(i) = sum(a.*mem) + x(i); % sum of inner product + input
mem(2:nm) = mem(1:nm-1); % shift memory
mem(1) = y(i); % y(i) -> first mem value
end
for i = nx+1:ny % response when input exhausted
y(i) = sum(a.*mem); % sum of inner product
mem(2:nm) = mem(1:nm-1); % shift memory
mem(1) = y(i); % y(i) -> first mem value
end
Matlab script
clear
x = 1; % define input-sample sequence
ny = 51; % output sequence size
a = -0.9; % first-order coefficient
y = f_AR_filter(x,a,ny);
subplot(2,2,1),stem(y) % plot output (unit-sample response)
axis([0 51 1.1*min(y) 1.1*max(y)])
str =[’a= ’ num2str(a)];
title(str); xlabel(’i’); ylabel(’y_i’)
a = 1; % first-order coefficient
y = f_AR_filter(x,a,ny);
subplot(2,2,2),stem(y) % plot output (unit-sample response)
axis([0 50 1.1*min(0,min(y)) 1.1*max(y)]) % solves problem when all y vals are equal
str =[’a= ’ num2str(a)];
title(str); xlabel(’i’); ylabel(’y_i’)
a = 1.1; % first-order coefficient
y = f_AR_filter(x,a,ny);
subplot(2,2,3),stem(y) % plot output (unit-sample response)
axis([0 51 1.1*min(y) 1.1*max(y)])
str =[’a= ’ num2str(a)];
title(str); xlabel(’i’); ylabel(’y_i’)
a = 10; % first-order coefficient
y = f_AR_filter(x,a,ny);
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
102 CHAPTER 8. DIGITAL SIGNAL PROCESSING
0.5 0.8
0.6
yi
yi
0
0.4
−0.5
0.2
0
0 10 20 30 40 50 0 10 20 30 40 50
i 49
i
a= 1.1 x 10 a= 10
120 10
100
8
80
6
i
yi
y
60
4
40
20 2
0 10 20 30 40 50 0 10 20 30 40 50
i i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.2. MATLAB PROJECTS 103
Project 8.6 (Cascading first-order AR digital filters) Compose a Matlab script that cascades two AR
filters with the output of the first forming the input to the second. to the unit-sample response of the
cascaded connection of two identical first-order AR systems with a = 0.95.
(ans: Matlab script that plots index and output values to start plot at i = 0.
clear
x = 1; % define input-sample sequence
ny = 101; % output sequence size
i = 0:ny-1; % define i index
a = 0.95; % first-order coefficient
y1 = f_AR_filter(x,a,ny);
subplot(2,1,1),stem(i,y1) % plot output (unit-sample response)
axis([0 ny-1 1.1 *min(y1) 1.1*max(y1)])
str =[’Output of first AR filter with a= ’ num2str(a)];
title(str); xlabel(’i’); ylabel(’y1_i’)
y2 = f_AR_filter(y1,a,ny);
subplot(2,1,2),stem(i,y2) % plot output (unit-sample response)
axis([0 ny-1 1.1 *min(y2) 1.1*max(y2)])
str =[’Output of second AR filter with a= ’ num2str(a)];
title(str); xlabel(’i’); ylabel(’y2_i’)
0.8
0.6
i
y1
0.4
0.2
0 10 20 30 40 50 60 70 80 90 100
i
4
3
2
1
0 10 20 30 40 50 60 70 80 90 100
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
104 CHAPTER 8. DIGITAL SIGNAL PROCESSING
Project 8.7 (Second-order AR digital filter) Compose a Matlab script to compute and plot in one fig-
ure the hi for 0 ≤ i ≤ 50 for the second-order AR filters having the following coefficients.
1. r = 0.9, ω = π/8
2. r = 1.1, ω = π/8
3. r = 0.9, ω = 0
(ans: A second-order filter is implemented by defining the a coefficient array with two elements that is
applied to that f_AR_filter function.
clear
x = 1; % define input sequence
ny = 51; % output sequence size
i = 0:ny-1; % define i index
1
y1i
0
0 5 10 15 20 25 30 35 40 45 50
i
Output of second−order AR filter with r= 1.1 and ω = 0.3927
300
200
100
y2i
0
−100
0 5 10 15 20 25 30 35 40 45 50
i
Output of second−order AR filter with r= 0.9 and ω = 0
4
3
y3i
2
1
0 5 10 15 20 25 30 35 40 45 50
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
8.2. MATLAB PROJECTS 105
Project 8.8 (Second-order ARMA filter) Using Example 16.41 as a guide, compose Matlab code to
implement an ARMA system that has
hi = sin(ωo i) for 0 ≤ i ≤ 64
for ωo = π/8. Hint: the difference equation is
yi = 2 cos(ωo )yi−1 − yi−2 + sin(ωo )xi−1 for 0 ≤ i ≤ 64
Using subplot(3,1,n),stem(.), plot hi computed directly from the sine function, yi , and the error hi − yi .
(ans:
x = 1; % define input-sample sequence
ny = 65; % output sequence size
i = 0:ny-1; % define i index
omega = pi/8; % radian frequency
h = sin(omega.*i);
subplot(3,1,1);stem(i,h) % plot sine sequence
str =[’sine sequence with \omega = ’ num2str(omega)];
title(str); xlabel(’i’); ylabel(’h_i’)
axis([0 64 1.1*min(y) 1.1*max(y)])
−0.5
−1
0 10 20 30 40 50 60
i
Output of second−order ARMA filter with r=1 and ω = 0.3927
1
0.5
0
yi
−0.5
−1
0 10 20 30 40 50 60
i
−15 error sequence
x 10
2
1
εi
0
−1
−2
0 10 20 30 40 50 60
i
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
106 CHAPTER 8. DIGITAL SIGNAL PROCESSING
© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.