0% found this document useful (0 votes)
141 views35 pages

T-61.246 Digital Signal Processing and Filtering T-61.246 Digitaalinen Signaalink Asittely Ja Suodatus Description of Example Problems

This document provides an overview of example problems for a digital signal processing course. It lists 58 topics related to discrete-time signals and systems, digital filter design, implementation issues, and multirate systems. These include topics like signals and sequences, the discrete Fourier transform, sampling and aliasing, filter types and structures, and filter design methods. The document indicates that solutions to the example problems start on page 23.

Uploaded by

Doğukan Turan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views35 pages

T-61.246 Digital Signal Processing and Filtering T-61.246 Digitaalinen Signaalink Asittely Ja Suodatus Description of Example Problems

This document provides an overview of example problems for a digital signal processing course. It lists 58 topics related to discrete-time signals and systems, digital filter design, implementation issues, and multirate systems. These include topics like signals and sequences, the discrete Fourier transform, sampling and aliasing, filter types and structures, and filter design methods. The document indicates that solutions to the example problems start on page 23.

Uploaded by

Doğukan Turan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

T-61.246 DSP 2005 1/140 T-61.

246 DSP 2005 2/140

T-61.246 Digital Signal Processing and Filtering Description of Example Problems


T-61.246 Digitaalinen signaalinkäsittely ja suodatus # Subject Mitra/Simula
Math Background 1-11
Exercise material for autumn 2005 by professor Olli Simula and assistant Jukka Parviainen. 1 complex numbers, Carthesian and polar coordinate systems, Euler’s
Corrections and comments to t61246@cis.hut.fi, thank you! formula
2 Euler’s formula, cosine and sine
3 complex numbers, graphical notation
This copy belongs to: 4 complex-valued function
5 cosine function, amplitude, frequency, phase
6 logarithm, decibels, sinc, modulo, binary number representation
7 roots of a polynomial
8 complex-valued function, roots of polynomial
9 partial fraction expansion / decomposition
10 sum of geometric series
11 integral transforms
Discrete-time Signals and Systems in Time Domain 12-23 Ch 2
Contens 12 signals and sequences, unit impulse and unit step functions (δ[n],
Description of Example Problems 2 µ[n])
13 periodic signals
Example Problems 4 14 flow / block diagram of a discrete-time system
15 recognition of LTI systems
Solutions to Example Problems 23 16 math for LTI systems
17 impulse response h[n]
Terminology list 122 18 linear convolution y[n] = h[n] ~ x[n]
19 convolution as products of polynomials
Introduction to Matlab 131 20 deconvolution
Introduction to LATEX 137 21 parallel and cascade (series) LTI systems
22 matched filter
Formula tables 138 23 auto- and cross-correlation
Discrete-time Signals and Systems in Frequency Domain 24-28 Ch 3
24 spectrum, DTFT, DFT
25 spectrum, DTFT
26 DTFT, computation from definition
27 DFT
28 circular convolution
System Analysis in Frequency Domain 29-33 Ch 4
29 analysis of LTI system in frequency domain
30 amplitude response grafically from pole-zero-plot
31 analysis of LTI system in frequency domain
32 transfer function, region of convergence (ROC)
33 filter types: allpass, zero-phase, linear-phase, minimum-phase,
maximum-phase
Sampling and Aliasing 34-38 Ch 5
34 impulse train and Fourier-series
35 sampling in frequency domain
continued on next page

T-61.246 DSP 2005 3/140 T-61.246 DSP 2005 4/140 PROBLEMS

continued from previous page T-61.246 Digital Signal Processing and Filtering
# Subject Mitra/Simula Example problems for autumn 2005.
36 sampling in frequency domain Solutions start from Page 23.
37 aliasing
38 anti-aliasing filter
System Structures 39-43 Ch 6
39 LTI subsystems
Problems
40 polyphase structure
41 canonic structure Math Background 1-11
42 direct form (DF) structures 1. Complex numbers in Carthesian (rectangular) coordinates z = x + yj (or i) and polar
43 direct form, transpose coordinates z = r · ejθ . The complex conjugate z ∗ is z ∗ = x − yj = r · e−jθ . Euler’s
Digital Filter Design 44-49 Ch 7 formula ejω = cos(ω) + j sin(ω).
44 filter specifications
45 analog filter approximations a) Express z = 2e−jπ in rectangular coordinates.
46 scaling factor b) Express z = −1 + 2j in polar coordinates.
47 bilinear transform and impulse-invariant method in digital filter
design c) Which (two) angles satisfy sin(ω) = 0.5?
48 FIR-window method in digital filter design d) What are z + z ∗ , |z + z ∗ |? and ∠(z + z ∗ )? What are zz ∗ , |zz ∗ |? and ∠zz ∗ ?
49 computational issues on IIR / FIR filters
Implementation Issues 50-54 Ch 8, 9 2. The important Euler’s formula is ejθ = cos(θ) + j · sin(θ). Cosine is even function f (x) =
50 FFT f (−x) and sine is odd function f (x) = −f (−x).
51 fixed-point binary number representations
a) Express with cosines and sines: ejθ + ej(−θ) .
52 quantization, error densities
53 quantization noise b) Express with cosines and sines: ejθ − ej(−θ) .
54 error-feedback structure c) Express with cosines and sines: ejπ/8 · ejθ − ej(−π/8) · ej(−θ) .
Multirate Systems 55-58 Ch 10
55 up- and downsampling in time- and frequency domain 3. Consider the following three complex numbers
56 multirate system analysis
z1 = 3 + 2j
57 linearity of up- and downsampling systems
58 filter bank z2 = −2 + 4j
z3 = −1 − 5j

a) Draw the vectors z1 , z2 , and z3 separately in complex plane.


b) Draw and compute the sum z1 + z2 + z3 .
c) Draw and compute the weighted sum z1 − 2z2 + 3z3 .
d) Draw and compute the product z1 · z2 · z3 .
e) Compute and reduce the division z1 /z2 .

4. Examine a complex-valued function

H(ω) = 2 − e−jω

where ω ∈ [0 . . . π] ∈ R.

a) Compute values of Table 1 with a calculator. Euler: ejω = cos(ω) + j sin(ω).


b) Draw the values at ω = {0, π/4, . . . , π} into complex plane (x, y). Interpolate
smoothly between the points.
c) Sketch |H(ω)| as a function of ω. Interpolate.
d) Skecth ∠H(ω) as a function of ω. Interpolate.
T-61.246 DSP 2005 5/140 PROBLEMS T-61.246 DSP 2005 6/140 PROBLEMS

5. A cosine signal can be represented using its angular frequency Ω or frequency f , amplitude 8. Examine a complex-valued function (z ∈ C)
A and phase θ:
x(t) = A cos(Ωt + θ) = A cos(2πf t + θ) 1 + 0.5z −1 + 0.06z −2
H(z) =
1 − 1.4z −1 + 0.48z −2
a) Estimate A, f, θ for the cosine x1 (t) in Figure 1(a).
a) Multiply both sides by z 2 .
b) Sketch a cosine x2 (t), with A = 2, angular frequency 47 rad/s and angle −π/2.
b) Solve z 2 + 0.5z + 0.06 = 0.
c) Express x2 (t) in (b) using exponential functions.
c) Solve z 2 − 1.4z + 0.48 = 0.
1
2 d) H(z) can be written with five values complex values K, z1 , z2 , p1 , and p2
1.5

1 (z − z1 ) · (z − z2 )
0.5 H(z) = K ·
0.5 (z − p1 ) · (z − p2 )
0 0

−0.5
What are the five values?
−0.5 −1 e) What are the coefficients of H(z). What are the roots of H(z)? What is the order of
−1.5 the numerator polynomial of H(z)? What is the order of the denominator polynomial
−1 −2 of H(z)?
−0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0 0.02 0.04 0.06 0.08 0.1 0.12

9. Partial fraction expansion (osamurtohajotelma, osamurtokehitelmä) is used to divide a


Figure 1: Cosine x1 (t) (left) and x2 (t) (right) in Problem 5.
high-order rational expression into a sum of low-order rational expressions. For example,
1/(x2 + 3x + 2) = 1/(x + 1) − 1/(x + 2).
6. Some elementary functions and notations.
Decomposition is quite trivial if there are not multiple roots neither is the order of numer-
a) Compute with a calculator: log8 7. ator polynomial as big or bigger as the order of the denominator polynomial. For more
complicated cases, see Mitra Sec. 3.9., or any other math reference.
b) The power of signal is attenuated from 10 to 0.01. How much is the attenuation in
decibels? a) Decompose f (x) = 1/(x2 + 1) into sum of first-order expressions.
P
c) Sketch the curve p(x) = +N k=−N kx for various N . b) Decompose H(z) = (0.4 − 0.2z −1 )/(1 − 0.1z −1 − 0.06z −2 ) into sum of first-order
d) Sinc-function is useful in the signal processing. It is defined sinc(x) = sin(πx)/(πx). expressions.
Also it is known that sin(x)/x → 1, when x → 0, and with sinc-function sinc(0) = 1. P∞
Consider h(n) = sin(0.75πn)/(πn). What is h(0)? 10. When the ratio q in geometric series is |q| < 1, the sum of series converges to k=0 qk =
P
1/(1 − q), and correspondingly N k
k=0 q = (1 − q
N +1
)/(1 − q).
e) Modulo-N operation for number x is written here as < x >N . What is < −4 >3 ?
Other known series are {1/n} and {1/n2 }. Notice that the former does not converge,
f) What is the binary number (1001011)2 as a decimal number?
while the latter does.
7. Roots
√ of√a polynomial p(x) can be found from p(x) = 0. N th root of z = r ej(θ+2πk) is P∞ k
N
z = | N r| · ej(2π k/N +θ/N ) , where k = 0 . . . N − 1. a) What is sum of series S = k=0 (0.5) .
P
b) S = ∞ k=10 (−0.6)
k−2
.
2
a) Compute roots of H(z) = z + 2z + 2. P
c) S = ∞ k=2 (0.8 k−2
· e−jωk ).
b) Compute roots of H(z) = 1 + 16z −4 .
c) Compute long division (4z 4 − 8z 3 + 3z 2 − 4z + 6)/(2z − 3). 11. Integral transforms, like Fourier-transforms, play an important role in signal processing.

a) List all integral transforms that are used in previous signal processing courses.
ω x = Real(H(ω)) y = Imag(H(ω)) r = |H(ω)| θ = ∠H(ω) R 4 −jωt
b) Compute the integral X(ω) = 0
e dt.
0
π/4
π/2
Discrete-time Signals and Systems in Time Domain 12-23
3π/4 12. The unit impulse
( function δ[n] and the unit step function
( µ[n] (or u[n]) are defined
π 1, when n = 0 1, when n ≥ 0
δ[n] = µ[n] =
Table 1: Problem 4: values of a complex-valued function in rectangular (x, y) and polar (r, θ) 0, when n 6= 0 0, when n < 0
coordinates. Sketch the following sequences around the origo

T-61.246 DSP 2005 7/140 PROBLEMS T-61.246 DSP 2005 8/140 PROBLEMS

a) x1 [n] = sin(0.1πn) x[n] y[n] x[n] y[n]

b) x2 [n] = sin(2πn)
−1 −1
D z z
c) x3 [n] = δ[n − 1] + δ[n] + 2δ[n + 1]
d) x4 [n] = δ[−1] + δ[0] + 2δ[1] −2 −2 2
e) x5 [n] = µ[n] − µ[n − 4] D z−1

f) x6 [n] = x3 [−n + 1]
(a) (b)
13. Continuous-time signal x(t) is periodic, if there exists period T ∈ R, for which x(t) =
x(t + T ), ∀t. Discrete-time signal (sequence) x[n] is periodic, if ∃N ∈ Z, for which v[n]
x[n] = x[n + N ], ∀n ∈ Z. The fundamental period T0 (or N0 ) is the smallest period x[n] +
bigger than 0. a b
Which of the following signals are periodic? Define the length of the fundamental period x[n] y[n]
for periodic signals.

a) x(t) = 3 cos( 8π
31
t) y[n] + D
cos( ω n)
b) x[n] = 3 cos( 8π
31
n) c
(c) (d)
c) x(t) = cos( π8 t2 )
d) x[n] = 2 cos( π6 n − π/8) + sin( π8 n) Figure 3: Discrete-time systems for Problems 14 and ??.
e) x[n] = {. . . , 2, 0, 1, 2, 0, 1, 2, 0, 1, . . .} P2
P
f) x[n] = +∞ b) y[n] = γ + x[n − l], γ is a nonzero constant,
k=−∞ δ[n − 4k] + δ[n − 4k − 1]
l=−2
c) y[n] = αx[−n], α is a nonzero constant.
14. There are some basic operations on sequences (signals) in discrete-time systems (x refers
to input to the system / operation, y output) shown also in Figure 2. 17. Impulse response h[n] is the response of the system to the input δ[n].

x 1 [n] x[n] ax[n] x[n] x[n−1] x[n] a) What is the impulse response of the system in Figure 3(a)? What is the connection
D
a x[n] to the difference equation? Is this LTI system stable/causal?
x 2 [n] x 1 [n]+x 2 [n] x[n] x[n−1] b) What are the first five values of impulse response of the system in Figure 3(b)? Hint:
z−1 x[n]
(a) (b) (c) (d) Fetch the input δ[n] and read what comes out. Is it possible to say something about
stability or causality of the system?
c) What are the first five values of impulse response of the system in Figure 3(d)?
Figure 2: Problem 14: Basic operations in discrete-time systems, (a) sum of sequencies, (b)
amplification by constant, (c) unit delay (D, T , or z −1 , and (d) branch / pick-off node. 18. Linear convolution of two sequences is defined

X
Express the input-output relations of the discrete-time systems in Figure 3. y[n] = h[n] ~ x[n] = x[n] ~ h[n] = x[k] h[n − k]
k=−∞
15. Look at the flow (block) diagrams in Figure 4.
a) Compute x[n] ~ h[n], when
a) What does LTI mean? In what ways can the system be proved (Problem 16) or x[n] = δ[n] + δ[n − 1], and h[n] = δ[n] + δ[n − 1].
shown to be LTI? What is the length of the convolution result?
b) Which systems are linear and time-invariant (LTI) without any computation? b) Compute x1 [n] ~ x2 [n], when
c) Which systems have feedback? x1 [n] = δ[n] + 5δ[n − 1], and x2 [n] = −δ[n − 1] + 2δ[n − 2] − δ[n − 3] − 5δ[n − 4].
What is the length of the convolution result? Where does the output sequence start?
d) Which LTI systems are FIR and which are IIR?
c) Compute h[n] ~ x[n], when
16. For each the following discrete-time systems, determine whether or not the system is (1) h[n] = 0.5n µ[n], and x[n] = δ[n] + 2δ[n − 1] − δ[n − 2].
linear, (2) causal, (3) stable, and (4) shift-invariant. The sequences x[n] and y[n] are the What is the length of the convolution result?
input and output sequences of the system.
19. Consider a LTI-system with impulse response h[n] = δ[n−1]−δ[n−2] and input sequence
a) y[n] = x3 [n], x[n] = 2δ[n] + 3δ[n − 2].
T-61.246 DSP 2005 9/140 PROBLEMS T-61.246 DSP 2005 10/140 PROBLEMS

x[n] h4[n]
-1 h1[n] h2[n]
z
-0.75 h1[n] h2[n] h3[n]
-1
z h5[n]
x[n] y[n]
0.5 0.5 0.5 h3[n] h4[n] h5[n]
x[n] y[n] y[n] (a) (b)
-1 -1 -1 0.75
z z z
-0.75 0.5 -0.75 -1
z Figure 6: LTI systems in Problem 21.
i ii iii
v[n]
x[n] + The (binary) signal to be detected is given by s[n] = {1, 1, 1, −1, −1, 1, −1}. Consider an
a b
input sequence x[n] which is a periodic sequence repeating s[n]. Determine h[n] and the
result of filtering y[n] = h[n] ~ x[n].
x[n] 1/2 y[n]
23. Cross-correlation sequence rxy [l] of two sequences and autocorrelation sequence rxx [l] with
y[n] + D lag l = 0, ±1, ±2, . . . are defined
1 c ∞ ∞
X X
iv v rxy [l] = x[n]y[n − l] rxx [l] = x[n]x[n − l]
n=−∞ n=−∞
Figure 4: Flow diagrams of Problem 15.
Determine the autocorrelation sequence of the sequence

x1 [n] = αn µ[n], |α| < 1


a) What is the length of convolution of h[n] and x[n] (without computing convolution
itself)? Which index n is the first one having a non-zero item? and show that it is an even sequence. What is the location of the maximum value of the
b) Compute convolution y[n] = h[n] ~ x[n] autocorrelation sequence?
c) Consider polynomials S(x) = 2 + 3x2 and T (x) = x − x2 . Compute the product
U (x) = S(x) · T (x) Discrete-time Signals and Systems in Frequency Domain 24-28
d) Check the result by computing the polynomial division T (x) = U (x)/S(x). 24. Sketch the following signals in time-domain and their (amplitude) spectra in frequency-
domain.
20. The impulse response h1 [n] of a LTI system is known to be h1 [n] = µ[n] − µ[n − 2]. It is
connected in cascade (series) with another LTI system h2 as shown in Figure 5. a) x1 (t) = cos(2π 500 t)
b) x2 (t) = 4 cos(2π 200 t) + 2 sin(2π 300 t)
x[n] y[n]
h1[n] h2[n] h1[n] c) x3 (t) = e−j(2π 250t) + ej(2π 250t)
d) x4 (t) = x1 (t) + x2 (t) + x3 (t)
Figure 5: The cascade system of Problem 20.
25. Suppose that a real sequence x[n] and its discrete-time Fourier transform (DTFT) X(ejω )
are known. The sampling frequency is fs . At angular frequency ωc = π/4: X(ej(π/4) ) =
Compute the impulse response h2 [n], when it is known that the impulse response h[n] of 3 + 4j. Determine
the whole system is shown in Table 2 below.
a) |X(ej(π/4) )| b) ∠X(ej(π/4) )
n <0 0 1 2 3 4 >4 c) X(ej(−π/4) ) d) X(ej(π/4+2π) )
h[n] 0 1 5 9 7 2 0 e) If fs = 4000 Hz, what is fc

Table 2: Impulse response of the cascade system in Problem 20. 26. Compute DTFT for each of the following sequences using the definition

X
21. LTI systems are commutative, distributive and associative. Determine the expression for X(ejω ) = x[n]e−jωn
the impulse response of each of the LTI systems shown in Figure 6. n=−∞

22. The impulse response of a digital matched filter, h[n], is the time-reversed replica of the a) x1 [n] = δ[n − 2]
signal to be detected. The time-shift is needed in order to get a causal filter. b) x2 [n] = 0.5n µ[n]

T-61.246 DSP 2005 11/140 PROBLEMS T-61.246 DSP 2005 12/140 PROBLEMS

c) x3 [n] = a[n] · cos( π5 n) 30. The z-transform of the impulse response h[n] of the LTI system is the transfer function
H(z) (with certain ROCs). It can be written as a rational function in z −1 as follows
27. The exponent term in DFT/IDFT is commonly written WN = e−j2π/N .
B(z) b0 + b1 z −1 + b2 z −2 + . . . + bM z −M
a) Compute and draw in complex plane values of W3k H(z) = =
A(z) a0 + a1 z −1 + a2 z −2 + . . . + aN z −N
b) Compute 3-DFT for the sequence x[n] = {1, 3, 2}.
(1 − z1 z −1 ) · (1 − z2 z −1 ) · . . . · (1 − zM z −1 )
28. Let g[n] and h[n] be two finite-length sequences given below: = K ·
(1 − p1 z −1 ) · (1 − p2 z −1 ) · . . . · (1 − pN z −1 )

  −3, for n = 0, where bi are the coefficients of the numerator polynomial B(z), and ai are the coefficients
 5, for n = 0, 

4, for n = 1, of the denominator polynomial A(z). The order of H(z) is max{M, N }. Those points
g[n] = 2, for n = 1, h[n] =
  0, for n = 2, zi where B(z) = 0 are called “zeros”, and points pi where A(z) = 0 are called “poles”.
4, for n = 2 

2, for n=3 The figure with zeros (circles) and poles (crosses) plotted in the complex plane is called
“pole-zero plot” (diagram) of the transfer function. The amplitude response |H(ejω )| can
a) Determine the linear convolution yL [n] = g[n] ~ h[n].
be (easily/roughly) seen from that.
b) Extend g[n] to length-4 sequence ge [n] by zero-padding and compute the circular
Consider the pole-zero plots in Figure 8.
convolution yC [n] = ge [n]
4 h[n].

c) Explain the result! How the result of (b) can be used in overlap-save method when a) What is the order of each transfer function?
the linear convolution of finite sequence and infinite sequence are computed. b) Are they FIR or IIR?
c) Sketch the amplitude response for each filter.
System Analysis in Frequency Domain 29-33 d) What could be the transfer function of each filter?
29. Consider a LTI system depicted in Figure 7 with registers having initial values of zero
and the input sequence x[n] = (−0.8)n µ[n].
1 1 1
Imaginary Part

Imaginary Part

Imaginary Part

x[n] y[n]
4
0 0 0
z −1 z −1
0.8 0.9
−1 −1 −1
z−1 −1 0 1 −1 0 1 −1 0 1
−0.2 Real Part Real Part Real Part

Figure 8: Pole-zero plots of LTI systems in Problem 30.

Figure 7: LTI system of Problem 29.


31. Consider the filter described in Figure 9.

a) What is the difference equation of the system? x[n] y[n]


b) Compute X(z) using the definition of z-transform or consult the z-transform table.
c) Apply z-transform to the difference equation. What is the transfer function H(z) = Z-1 Z-1
Y (z)/X(z)? Where are the constant multipliers of the system seen in Figure 7 in
difference equation and in transfer function? Hint: the z-transform of K w[n − n0 ]
is K z −n0 W (z).
Z-1 Z-1
d) Now it is possible to compute the output y[n] without convolution in time-domain
using the convolution theorem
-1 -0.81
y[n] = h[n] ~ x[n] ↔ Y (z) = H(z) · X(z)
Figure 9: LTI system of Problem 31.
Write down the equation for Y (z), use partial fraction expansion in order to achieve
rational polynomials of first order, and then use the inverse z-transform (equation
a) Derive the difference equation of the system.
in (b)).
T-61.246 DSP 2005 13/140 PROBLEMS T-61.246 DSP 2005 14/140 PROBLEMS

b) Calculate the transfer function H(z). 35. Impulse train in Problem 34 can be also expressed as a Fourier transform
c) Calculate the zeros and poles of H(z). Sketch the pole-zero plot. Is the system ∞
2π X
stable and/or causal? P (jΩ) = δ(Ω − k Ωs )
Ts k=−∞
d) If the region of convergence (ROC) of H(z) includes the unit circle, it is possible to
derive frequency response H(ejω ) by applying z = ejω . Do this! Sampling can be modelled as multiplication in time domain x[n] = xp (t) = x(t)p(t).
e) Sketch the magnitude (amplitude) response |H(ejω )| roughly. Which frequency gives What is Xp (jΩ) for an arbitrary input spectrum X(jΩ)?
the maximum value of |H(ejω )|? (If you want to calculate magnitude response Hints: Fourier transform of a periodic signal (Fourier series)
explicitely, calculate |H(ejω )|2 = H(ejω )H(e−jω ) and use Euler’s formula.)

f) Compute the equation for the impulse response h[n] using partial fraction expansion X
X(jΩ) = 2πak δ(Ω − kΩ0 )
and inverse z-transform.
n=−∞

32. The transfer function of a filter is Multiplication of signals in time domain corresponds to convolution of transforms in
1 − z −1 frequency domain:
H(z) =
1 − 2z −1 + 0.75z −2 1  1
Z ∞
x1 (t) · x2 (t) ↔ X1 (jΩ) ~ X2 (jΩ) = X1 (jθ) · X2 (j(Ω − θ))dθ
a) Compute the zeros and poles of H(z). 2π 2π −∞
b) What are the three different regions of convergence (ROC)?
36. Suppose that a continuous-time signal x(t) and its spectrum |X(jΩ)| in Figure 10 are
c) Determine the ROC and the impulse response h[n] so that the filter is causal. known.
d) Determine the ROC and the impulse response h[n] so that the filter is stable.
|X(jw)|
33. Examine the following five filters and connect them at least to one of the following cat-
egories (a) zero-phase, (b) linear-phase, (c) allpass, (d) minimum-phase, (e) maximum- 1
phase.

h1 [n] = −δ[n + 1] + 2δ[n] − δ[n − 1] fh


1 + 3z −1 + 2.5z −2 Figure 10: Spectrum X(jΩ) in Problem 36.
H2 (z) =
1 − 0.5z −1
y3 [n] = 0.5y3 [n − 1] + x[n] + 1.2x[n − 1] + 0.4x[n − 2]
0.2 − 0.5z −1 + z −2 The highest frequency component in the signal is fh . The signal is sampled with frequency
H4 (z) = fs , i.e. the interval between samples is Ts = 1/fs : x[n] = x(nTs ). Sketch the spectrum
1 − 0.5z −1 + 0.2z −2
|X(ejω )| of the discrete-time signal, when
H5 (ejω ) = −1 + 2e−jω − e−2jω
a) fh = 0.25 fs
Sampling and Aliasing 34-38 b) fh = 0.5 fs
34. Show that the periodic impulse train p(t) c) fh = 0.75 fs


X 37. Consider a continuous-time signal
p(t) = δ(t − nT ) 
n=−∞ cos(2πf1 t) + cos(2πf2 t) + cos(2πf3 t), t ≥ 0
x̃(t) =
0, t<0
can be expressed as a Fourier series
where f1 =100 Hz, f2 =300 Hz and f3 =750 Hz. The signal is sampled using frequency fs .
∞ ∞
1 X j(2π/T )kt 1 X jΩT kt Thus, a discrete signal x[n] = x̃(nTs ) = x̃(n/fs ) is obtained.
p(t) = e = e ,
T k=−∞ T k=−∞ Sketch the magnitude of the Fourier spectrum of x[n], the sampled signal, when fs equals
to (i) 1600 Hz (ii) 800 Hz (iii) 400 Hz.
where ΩT = 2π/T is the sampling angular frequency.
Use an ideal reconstruction lowpass filter whose cutoff frequency is fs /2 for each case.
What frequency components can be found in reconstructed analog signal xr (t)?

T-61.246 DSP 2005 15/140 PROBLEMS T-61.246 DSP 2005 16/140 PROBLEMS

38. Suppose that there is an analog signal which will be sampled with 8 kHz. The interesting c) Compute H(z)H(z −1 ) (the squared amplitude response). What is the type of this
band is 0 . . . 2 kHz. Sketch specifications for an anti-aliasing filter. Determine the order filter (lowpass/highpass/bandpass/bandstop/allpass)?
of the filter when using Butterworth approximation and minimum stopband attenuation
is 50 dB. The variables in Table 38: Ωp is the passband edge frequency (interesting part), 42. The filter in Figure 13 is in canonic direct form II.
ΩT is the sampling frequency, and Ω0 is the frequency after which the aliasing components
x[n] w[n] y[n]
are small enough.

Ω0 = 2Ωp 3Ωp 4Ωp


z −1
Attenuation (dB) 6.02N 9.54N 12.04N 0.8
0.9
ΩT = 3Ωp 4Ωp 5Ωp
Table 3: Approximate minimum stopband attenuation of a Butterworth lowpass filter. Mitra
Table 5.1, page 336. See the text in Problem 38 for details. z−1
−0.2

System Structures 39-43 Figure 13: The block diagram of direct form II of Problem 42.
39. Derive the transfer function of the feedback system shown in Figure 11.
a) Duplicate first the registers in the middle line and flip the order of “IIR” and “FIR”
x[n] w[n] y[n] parts (both subsystems are LTI!). The result should be a structure in Direct Form
E(z) F(z)
I, from which the transfer function H(z) can be easily constructed.
b) The transfer function can be obtained directly from the diagram using temporary
G(z)
variable w[n] and z-transform. What is H(z) in this (much harder) way?

Figure 11: System in Problem 39. 43. Develop a canonic direct form realization of the transfer function
2 + 4z −1 − 7z −2 + 3z −5
40. Develop a polyphase realization of a length-9 FIR transfer function given by H(z) =
1 + 2z −1 + 5z −3
8
X and then determine its transpose configuration.
H(z) = h[n]z −n
n=0
Digital Filter Design 44-49
with (a) 2 branches and (b) 4 branches.
44. Sketch the following specifications of a digital filter on paper. Which of the amplitude
41. Analyze the digital filter structure shown in Figure 12 and determine its transfer function responses of the realizations in Figure 14 do fulfill the specifications?
H(z) = Y (z)/X(z). Specifications: Digital lowpass filter, sampling frequency fT 8000 Hz, passband edge fre-
quency fp 1000 Hz, transition band 500 Hz (transition band is the band between passband
y[n] and stopband edge frequencies!), maximum passband attenuation 3 dB, minimum stop-
x[n]
z−1 z−1 band attenuation 40 dB.
K
−1 45. Connect first each amplitude response to the corresponding pole-zero plot in Figure 15.
Then recognize the following digital IIR filter algoritms: Butterworth, Chebyshev I,
A B Chebyshev II, Elliptic. The conversion from analog to digital form is done using bilinear
−1 transform.
z−1 z−1
46. Magnitude specifications are normally expressed in normalized form. The amplitude is
scaled to unity (0..1 or −∞..0 dB), and the frequency axis is scaled up to half of the
Figure 12: The flow diagram of the system in Problem 41. sampling frequency, 0..π, or 0..1. The first term of the denominator polynomial should
. also be 1.
Consider the following digital lowpass filter of type Chebyshev II:
a) Is the system LTI?
0.71 − 0.36z −1 − 0.36z −2 + 0.71z −3
b) Is it a canonic structure? H(z) = K ·
1 − 2.11z −1 + 1.58z −2 − 0.40z −3
T-61.246 DSP 2005 17/140 PROBLEMS T-61.246 DSP 2005 18/140 PROBLEMS

(a) Elliptic, N=4 (b) Chebychev II, N=10 (c) FIR/Hamming, N=50
Ideal LP wc = 3 π/4 → hd[n], n ∈ (−10,..,10)
0 0 0 1
0.8
−10 −10 −10

Magnitude
0.6
−20 −20 −20
0.4
dB −30 −30 −30

dB

dB
0.2
−40 −40 −40
0
−50 −50 −50
−0.2
−60 −60 −60
π ω −10 −5 0 5 10
−70 −70 −70
0 2000 4000 0 2000 4000 0 π/2 π
Hz Hz ω
Figure 16: Problem 48: (a) The amplitude response of the ideal lowpass filter, and (b) the
Figure 14: Three realizations in Problem 44: amplitude responses of (a) 4th order elliptic, (b) corresponding impulse response h[n] values. The cut-off frequency is at ωc = 3π/4.
10th order Chebychev II, (c) 50th order FIR using Hamming window.
0 0 1 1
0.5 0.5
a) Use the rectangular window of length 5, see Figure 17. The window function is
−20 −20
0 0 wr [n] = 1, −M ≤ n ≤ M, M = 2
−40 −40
−0.5 −0.5 b) Use the Hamming window of length 5, see Figure 17. The window function is
−60 −60 −1 −1
0 5000 10000 0 5000 10000  
−1 0 1 −1 0 1
2πn
0 0 wh [n] = 0.54 + 0.46 cos , −M ≤ n ≤ M, M = 2
1 1 2M
−20 −20 0.5 0.5

−40 −40
0 0 which results to wh [n] = {0.08, 0.54, 1, 0.54, 0.08}
−0.5 −0.5
−60 −60 c) Compare how the amplitude responses of the filters designed in (a) and (b) differ
0 5000 10000 0 5000 10000 −1 −1
−1 0 1 −1 0 1 assuming that the window size is high enough (e.g. M = 50).
(a) (b)
Rectangular window Hamming window

Figure 15: Problem 45. Digital filters from analog approximations through bilinear transform, 1 1

(a) amplitude responses with specifications, (b) pole-zero plots. 0.8 0.8

0.6 0.6

0.4 0.4

Normalize the maximum of the amplitude response to the unity (0 dB). 0.2 0.2

0 0
47. Consider the following prototype analog Butterworth-type lowpass filter −4 −2 0 2 4 −4 −2 0 2 4

1
HprotoLP (s) = Figure 17: Problem 48: (a) rectangular window wr [n] of length 5, and (b) Hamming window
s+1 wh [n] of length 5.
a) Form an analog first-order lowpass filter with cutoff frequency Ωc by substituting
H(s) = HprotoLP ( Ωsc ). Draw the pole-zero plot in s-plane.
b) Implement a discrete first-order lowpass filter HImp (z), whose cutoff frequency (-3 49. The following transfer functions H1 (z) and H2 (z) representing two different filters meet
dB) is at fc = 100 Hz and sampling rate is fs = 1000 Hz, applying the impulse- (almost) identical amplitude response specifications
invariant method to H(s). Draw the pole-zero plot of the filter HImp (z).
b0 + b1 z −1 + b2 z −2
c) Implement a discrete first-order lowpass filter HBil (z) with the same specifications H1 (z) =
applying the bilinear transform to H(s). Prewarp the edge frequency. Draw the 1 + a1 z −1 + a2 z −2
pole-zero plot of the filter HBil (z). where b0 = 0.1022, b1 = −0.1549, b2 = 0.1022, a1 = −1.7616, and a2 = 0.8314, and
48. Use windowed Fourier series method and design a FIR-type (causal) lowpass filter with 12
X
cutoff frequency 3π/4. Let the order of the filter be 4. H2 (z) = h[k]z −k
jω k=0
See the Figure 16, in left the amplitude response of the ideal lowpass filter H(e ) with
cut-off frequency at 3π/4. In right, the corresponding inverse transform of the desired where h[0] = h[12] = −0.0068, h[1] = h[11] = 0.0730, h[2] = h[10] = 0.0676,
ideal filter hd [n], which is sinc-function according to the transform pair rect(.) ↔ sinc(.): h[3] = h[9] = 0.0864, h[4] = h[8] = 0.1040, h[5] = h[7] = 0.1158, h[6] = 0.1201.
hd [n] = {. . . , −0.1592, 0.2251, 0.75, 0.2251, −0.1592, . . .} For each filter,

T-61.246 DSP 2005 19/140 PROBLEMS T-61.246 DSP 2005 20/140 PROBLEMS

a) state if it is a FIR or IIR filter, and what is the order a) Derive a formula for the roundoff noise variance when quantization is done before
b) draw a block diagram and write down the difference equation summations.
c) determine and comment on the computational and storage requirements b) Repeat (a) for the case where quantization is done after summations, i.e. a double
precision accumulator is used.
d) determine first values of h1 [n]
54. The quantization errors produced in digital systems may be compensated by error-shaping
Implementation Issues 50-54 filters(Section 9.10 in Mitra). The error components are extracted from the system and
processed e.g. using simple digital filters. This way the noise at the output of the system
50. Suppose that the calculation of FFT for a one second long sequence, sampled with 44100
can be reduced.
Hz, takes 0.1 seconds. Estimate the time needed to compute (a) DFT of a one sec-
ond long sequence, (b) FFT of a 3-minute sequence, (c) DFT of a 3-minute sequence. Consider a lowpass DSP system with a second-order noise reduction system in Figure 19.
The complexities of DFT and FFT can be approximated with O(N 2 ) and O(N log2 N ),
respectively. a) What is the transfer function of the system if infinite wordlength is used?
b) Derive an expression for the transform of the quantized output, Y (z), in terms of
51. Express the desimal number −0.3125 as a binary number using sign bit and four bits the input transform, X(z), and the quantization error, E(z), and hence show that
for the fraction in the format of (a) sign-magnitude, (b) ones’ complement, (c) two’s the error feedback network has no adverse effect on the input signal.
complement. What would be the value after truncation, if only three bits are saved.
c) Deduce the expression for the error feedback function.
52. In the following Figure 18, some error probability density functions of the quantization
d) What values k1 and k2 should have in order to work as an error-shaping system?
error are depicted.
f(e) (a)
z−1 z−1
e[n]
−∆/2 ∆/2 e k2 k1

f(e) (b) −1

x[n] y[n]
Q
1 w[n]
−∆/2 ∆/2 e
z−1 z−1

f(e) (c)
2 1.75
z−1 z−1

−∆ ∆ e
1 −0.81

Figure 18: Problem 52: Error density functions. Figure 19: Second-order system with second-order noise reduction in Problem 54.

(a) Rounding
(b) Two’s complement truncation Multirate Systems 55-58
(c) Magnitude (one’s complement) truncation 55. Consider a cosine sequence x[n] = cos(2π(f /fs )n) where f = 10 Hz and fs = 100 Hz as
is used to truncate the intermediate results. Calculate the expectation value of the quan- depicted in the top left in Figure 20. While it is a pure cosine, its spectrum is a peak at
tization error me and the variance σe2 in each case. the frequence f = 10 Hz (top middle) or at ω = 2πf /fs = 0.2π (top right).
R∞
E[E] = −∞ f (e) e de, Var[E] = E[(E − E[E])2 ] = E[E 2 ] − (E[E])2 a) Sketch the output sequence xu [n] with circles using up-sampler with up-sampling
53. In this problem we study the roundoff noise in direct form FIR filters. Consider an FIR factor L = 2, and draw its spectra into second row. Original sequence values of x[n]
filter of length N having the transfer function are marked with crosses. The spectrum in middle column is 0..200 Hz and in right
0..2π, i.e., 0..fs .
N
X −1 (
H(z) = h[k]z −k . x[n/L], n = 0, ±L, ±2L, . . .
xu [n] = Xu (ejω ) = X(ejωL )
k=0 0, otherwise
Sketch the direct form realization of the transfer function.
T-61.246 DSP 2005 21/140 PROBLEMS T-61.246 DSP 2005 22/140 PROBLEMS

b) Sketch the output sequence xd [n] with circles using down-sampler with down-sampling 58. Consider the multirate system shown in Figure 22 where H0 (z), H1 (z), and H2 (z) are ideal
factor M = 2, and draw its spectra into bottom row. lowpass, bandpass, and highpass filters, respectively, with frequency responses shown in
Figure 23(a)-(c). Sketch the Fourier transforms of the outputs y0 [n], y1 [n], and y2 [n] if
M −1
1 X the Fourier transform of the input is as shown in Figure 23(d).
xd [n] = x[nM ] Xd (ejω ) = X(ej(ω−2πk)/M )
M k=0
y0 [n]
H0 (z)
jω jω
x[n] = cos(2 π 10/100 n) |X(e )|, Hz |X(e )|, ω x π
x[n] y1 [n]
1 0.6 0.6 ↓3 ↑3 H1 (z)

0.4 0.4
x[n]

0 y2 [n]
0.2 0.2 H2 (z)
−1 0 0
0 0.05 0.1 0.15 0.2 0 50 100 150 200 0 1 2 Figure 22: Multirate system of Problem 58.
1
xu[n] = x[n/2]

0.6 0.6
0.4 0.4 H0 (ejω ) H1 (ejω )
0
0.2 0.2 1 1

−1 0 0
0 0.05 0.1 0.15 0.2 0 50 100 150 200 0 1 2
1
xd[n] = x[2n]

0.6 0.6 0 ω 0 ω
0 π/3 2π/3 π 0 π/3 2π/3 π
0.4 0.4
0
0.2 0.2
H2 (ejω ) X(ejω )
−1 0 0
0 0.05 0.1 0.15 0.2 0 50 100 150 200 0 1 2 1 1

Figure 20: Empty figures for Problem 55. The up-sampling factor L = 2, and the down-
sampling factor M = 2. Left column: sequence x[n] with circles, fill in the sequences xu [n]
0 ω 0 ω
and xd [n]. X-axis: time (0 . . . 0.2 s). Middle column: Spectrum X(ejf ) (10 Hz component, 0 π/3 2π/3 π 0 π/3 2π/3 π
100 Hz sampling frequency), fill in the spectra Xu (ejf ) and Xd (ejf ). X-axis: frequency
(0 . . . 200 Hz). Right column: Spectrum X(ejω ) (2π · (10/100) = 0.2π), fill in the spectra Figure 23: (a)-(c) Ideal filters H0 (z), H1 (z), H2 (z), (d) Fourier transform of the input of
Xu (ejω ) and Xd (ejω ). X-axis: angular frequency (0 . . . 2π). Problem 58.

56. Express the output y[n] of the system shown in Figure 115 as a function of the input x[n].

x[n] v[n] vu [n]


↓2 ↑2

z −1 z −1

w[n] wu [n] y[n]


↓2 ↑2

Figure 21: Multirate system of Problem 56.

57. Show that the factor-of-L up-sampler xu [n] and the factor-of-M down-sampler xd [n] de-
fined as in Problem 55 are linear systems.

T-61.246 DSP 2005 23/140 SOLUTIONS T-61.246 DSP 2005 24/140 SOLUTIONS

T-61.246 Digital Signal Processing and Filtering 2. Problem: Euler’s formula is ejθ = cos(θ) + j · sin(θ). Express with cosines and sines: (a)
Solutions for example problems for autumn 2005. ejθ + ej(−θ) , (b) ejθ − ej(−θ) , (c) ejπ/8 · ejθ − ej(−π/8) · ej(−θ) .
Corrections and comments to t61246@cis.hut.fi, thank you!
Solution: Euler’s formula ejθ = cos(θ) + j · sin(θ) can
√ be thought as a phasor going round
Solutions on the unit circle. It is unit circle because |ejθ | = cos2 + sin2 = 1 always. Real part of

e is cosine, and imaginary part is sine.
1. Problem:
a) Sum of exponentials at positive frequency θ and negative frequency −θ gives a real
a) Express z = 2e−jπ in rectangular coordinates. cosine at frequency θ.
b) Express z = −1 + 2j in polar coordinates. ejθ = cos(θ) + j · sin(θ)
c) Which (two) angles satisfy sin(ω) = 0.5? ej(−θ) = cos(−θ) + j · sin(−θ)
d) What are z + z ∗ , |z + z ∗ |? and ∠(z + z ∗ )? What are zz ∗ , |zz ∗ |? and ∠zz ∗ ? = cos(θ) − j · sin(θ)

Adding the first and list row we get


Solution:
ejθ + ej(−θ) = 2 cos(θ) ∈ R
a) “Brute force” using Euler’s formula and cos(−x) = cos(x) and sin(−x) = − sin(x),
b) In the same way as in (a)
z = 2e−jπ = 2(cos(−π) + j sin(−π)) = 2(cos(π) − j sin(π)) = −2
ejθ = cos(θ) + j · sin(θ)
or using directly the unit circle and seeing that when the angle is −π in radians
(−180 degrees) then e−jπ = −1. ej(−θ) = cos(−θ) + j · sin(−θ)
p √ = cos(θ) − j · sin(θ)
b) The radius r = (−1)2 + 22 = 5 ≈ 2.2 and the√angle in radians θ = π −
arctan(2/1) ≈ 2.03 ≈ 0.65π. So, z = −1 + 2j = 5 ej(π−arctan(2)) ≈ 2.2 e2.03j . Substracting the last from the first gives
Note! Always check the right quarter in the figure.
c) From Figure 24, ω1 = arcsin(0.5) = π/6 and ω2 = π − arcsin(0.5) = 5π/6 ejθ − ej(−θ) = 2j sin(θ) ∈ C
d) Summing can be graphically considered as concatenation of vectors. z + z ∗ = r(ejω + which is pure complex. In other words, cosine and sine are:
e−jω ) = 2r cos(ω) ∈ R. From previous, |z + z ∗ | = |2r cos(ω)| and ∠(z + z ∗ ) = 0.
Using Carthesians, z + z ∗ = 2x. cos(θ) = 0.5 · ejθ + 0.5 · ej(−θ)
Product of complex number and its complex conjugate: zz ∗ = (rejω )(re−jω ) = sin(θ) = −0.5j · ejθ + 0.5j · ej(−θ)
r 2 ej(ω−ω) = r 2 , and |zz ∗ | = r 2 and ∠zz ∗ = 0.
where 1/(2j) = −j/2 as shown in Problem 3(e).
Suorakulmainen ja polaarikoordinaatisto 2.5 c) This can be thought as phase shift. First, use the rule ex · ey = ex+y ,
1 2
ejθ · ejπ/8 = ej(θ+π/8)
y
z = x + yj 1.5 e−jθ · e−jπ/8 = e−j(θ+π/8)
0.5 jθ
=r sin(θ) =re 1
r
Now, we see using (b)
0 θ 0.5
x = r cos(θ)
0 ejπ/8 · ejθ − ej(−π/8) · ej(−θ) = 2j sin(θ + π/8)
−0.5 −0.5
z* Notice that each real cosine with positive angle and each real sine with positive angle
−1 can be replaced by two complex exponentials with positive and negative angles. When
−1
−1.5 considering Fourier analysis, the real cosine signal with frequency fc can be represented
−1 −0.5 0 0.5 1 −2 −1 0 1 in the spectrum with a peak at fc (in one-side spectrum) or with peaks at fc and −fc
(in two-side spectrum). Vice versa, if the two-side spectrum is not symmetric, then the
Figure 24: Problem 1, unit circle in complex plane (left), and points for (a), (b), and (c) (right). signal is not real but complex. More about this later in Fourier analysis.
T-61.246 DSP 2005 25/140 SOLUTIONS T-61.246 DSP 2005 26/140 SOLUTIONS

3. Problem: Consider the following three complex numbers z1 = 3 + 2j, z2 = −2 + 4j, and 4. Problem:
z3 = −1 − 5j. (a) Draw the vectors z1 , z2 , and z3 separately in complex plane. (b) Draw Examine a complex-valued function
and compute the sum z1 + z2 + z3 . (c) Draw and compute the weighted sum z1 − 2z2 + 3z3 .
(d) Draw and compute the product z1 · z2 · z3 . (e) Compute and reduce the division z1 /z2 . H(ω) = 2 − e−jω

where ω ∈ [0 . . . π] ∈ R.
Solution:
a) Compute values of Table 4 with a calculator. Euler: ejω = cos(ω) + j sin(ω).
a) Each number can be thought as a vector starting from origo and the other end at
point z. See Figure 25. b) Draw the values at ω = {0, π/4, . . . , π}. Interpolate.
b) Real parts and imaginary parts can be summed separately z = (3 − 2 − 1) + (2 + c) Sketch |H(ω)| as a function of ω. Interpolate.
4 − 5)j = −j. This can be expressed in polar coordinates z = ej(−π/2) , i.e. on unit d) Skecth ∠H(ω) as a function of ω. Interpolate.
circle (radius 1) and the angle one fourth a circle clockwise.
c) If you are computing without computer, be attentive and check twice that all coeffi-
Solution: In this course complex-valued functions are widely used, e.g. as frequency
cients are correctly reduced. z = (3 + 2j) − 2(−2 + 4j) + 3(−1
p − 5j) = 3 + 2j + 4 − responses of the systems or in Fourier transforms. The argument of the function is real-
8j − 3 − 15j = 4 − 21j. Again, in polar coordinates r = (4)2 + (−21)2 ≈ 21.38.
valued ω ∈ R, but the value of the function is (normally) complex H(ω) ∈ C due to
The angle θ = arctan((−21)/(4)) ≈ −1.38 ≈ −0.44π.
complex factor ejω . In case of the transfer function H(z) both z and H(z) are complex-
If z = −4 − 21j, then θ = arctan((−21)/(−4)) ≈ −π + 1.38 ≈ −1.76 ≈ −0.56π. valued.
Notice that now z is in the third quarter, so the angle 1.38 that calculator gives is
NOT the correct answer. a) Sometimes it is possible to simplify H(ω). However, normally it is useful to write
d) When using rectangular coordinates, multiply terms normally, j 2 = −1. The product down a suitable format for the use of the calculator. In this case, Carthesian coor-
in polar coordinates means multipling the lengths of vectors and summing the angles. dinate system with x and y is used:

z = ((3 + 2j) · (−2 + 4j)) · (−1 − 5j) H(ω) = 2 − e−jω = 2 − (cos(−ω) + j sin(−ω))
= (−14 + 8j) · (−1 − 5j) = 2 − cos(ω) +j sin(ω)
| {z } | {z }
= 54 + 62j x y
√ √ √
= 9 + 4 · 4 + 16 · 1 + 25 · ej(arctan(2/3)+arctan(4/(−2))+arctan((−5)/(−1))) The variables r and p θ of the polar coordinate system are received from the right-
≈ 82.2 · ej(0.27π) angled triangle: r = x2 + y 2 and θ = arctan(y/x).
On the other hand, in this case it is easily seen that there is only a circle (e−jω )
e) The denominator is now complex. If both sides are multiplied by the complex conju- whose origin is at z = 2.
gate then the denominator becomes real. Just as in Problem 1 z · z ∗ = |z|2 = r 2 ∈ R.
Notice also that 1/j is −j ((1/j) · (j/j) = j/j 2 ). ω x = Real(H(ω)) y = Imag(H(ω)) r = |H(ω)| θ = ∠H(ω)
0 1.0000 0 1.0000 0
z = (3 + 2j)/(−2 + 4j) | · (−2 − 4j)/(−2 − 4j) π/4 1.2929 0.7071 1.4736 0.1593π
= (2 − 12j)/20 π/2 2.0000 1.0000 2.2361 0.1476π
3 π/4 2.7071 0.7071 2.7979 0.0813 π
4 z
2
6 π 3.0000 0 3.0000 0
3
2 z 5 Table 4: Problem 8: values of a complex-valued function in rectangular (x, y) and polar (r, θ)
1
z
1 4 z3 2 coordinates. The row 3π/4 is highlighted for Figure 26.
0 3
−1
2 b) Take the columns x and y of Table 4 and sketch the curve like in Figure 26(left).
−2 z
1
−3 1 z There is a line drawn in the plot, from the origo to a point related to ω = 3π/4, i.e.
−4
z
0 (x, y). The length of the line is r and the angle between the line and x-axis is θ, so
−5 3
−1 it can be written in polar coordinates r ejθ .
−5 −4 −3 −2 −1 0 1 2 3 4 5 6 −1 0 1 2 3 4
c) Take the column r of Table 4 and sketch the curve like in Figure 26(middle). The
Figure 25: The vectors in Problem 3(a) and (b). plot shows the distance r from the origo to a point at given value of ω.
d) Take the column θ of Table 4 and sketch the curve like in Figure 26(right). The plot
shows the angle θ between the origo and a point at given value of ω.

T-61.246 DSP 2005 27/140 SOLUTIONS T-61.246 DSP 2005 28/140 SOLUTIONS

c) Using Euler’s formula, and properties of cosine (even function f (−x) = f (x)) and
2 0.2π sine (odd function f (−x) = −f (x)),

0.5π 3
ejω = cos(ω) + j sin(ω)
1 2 0.1π
+ e−jω = cos(ω) − j sin(ω)
r 1
0π θ π ejω + e−jω = 2 cos(ω)
0.5π π ω 0.5π π ω
1 2 3
ejω = cos(ω) + j sin(ω)
Figure 26: Problem 8: Plots of a complex-valued function. Left, H(ω) in complex plane; middle,
+ − e−jω = − cos(ω) + j sin(ω)
absolute values |H(ω)|; and right, angle ∠H(ω). The case when ω = 3π/4 is highlighted.
ejω − e−jω = 2j sin(ω)

5. Problem: Now, it can be seen that

x2 (t) = 2 cos(47t − π/2)


a) Estimate A, f, θ for the cosine x1 (t) in Figure 27(a).
= ej(47t−π/2) + e−j(47t−π/2)
b) Sketch a cosine x2 (t), with A = 2, angular frequency 47 rad/s and angle −π/2.
c) Express x2 (t) in (b) using exponential functions. which can be even “simplified” to x2 (t) = j[e−j47t − ej47t ].

1
2
Solution: There are a lot of variation in symbols in different signal processing books and 1.5
texts. There are probably also variation in these exercises. However, we try to use the 0.5 1
following symbols listed in Table 5. 0.5

0 0
symbol units meaning −0.5
f Hz frequency −0.5 −1
Ω rad/s angular frequency, Ω = 2πf −1.5

ω rad normalized angular frequency, ω = 2π(Ω/Ωs ) −1 −2


−0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0 0.02 0.04 0.06 0.08 0.1 0.12
fM AT LAB 1 normalized Matlab frequency, fM AT LAB = 2f /fs

Table 5: Problem 5, symbols of frequencies. fs refers to sampling frequency, and Ωs = 2πfs . Figure 27: Cosine x1 (t) (left) and x2 (t) (right) in Problem 5.

A cosine signal can be represented using its angular frequency Ω or frequency f , amplitude
A and phase θ:
x(t) = A cos(Ωt + θ) = A cos(2πf t + θ)
For a discrete sequence of numbers

x[n] = x(t)|t=nTs = x(t)|t=n/fs = A cos(2π(f /fs )n + θ) = A cos(ωn + θ)

where Ts is sampling interval (period), fs sampling frequency, and ω (normalized) angular


frequency.

a) Cosine oscillates between −0.8 and 0.8, so A = 0.8. There is no phase shift, θ = 0.
There is one oscillation in 0.2 seconds, so there are 5 periods in one second, f = 5
Hz, or Ω = 2πf = 10π rad/s.
Hence, x1 (t) = 0.8 cos(10πt).
b) x2 (t) can be written directly x2 (t) = 2 cos(47t − π/2).
If Ω = 47 rad/s, then f ≈ 7.5 Hz. In 0.1 seconds there are 0.75 periods. At t = 0,
x2 (0) = 2 cos(−π/2) = 0, and increasing. Note that cos(Ωt − π/2) ≡ sin(Ωt). The
curve is plotted in Figure 27(b).
T-61.246 DSP 2005 29/140 SOLUTIONS T-61.246 DSP 2005 30/140 SOLUTIONS

6. Problem: e) Normally we want to deal with numbers 0 . . . N − 1. Modulo-N with N = 3 means


simply that < x >N = x + kN, ∀k,
a) Compute with a calculator: log8 7.
b) The power of signal is attenuated from 10 to 0.01. How much is the attenuation in . . . =< −4 >3 =< −1 >3 =< 2 >3 = . . .
decibels?
P A circular buffer is implemented in the instruction sets of many DSPs. Assume that
c) Sketch the curve p(x) = +N k=−N kx for various N . there is a buffer of size 1024 bytes, with addresses 0x0000 to 0x03F F in hexadecimals.
d) Consider h(n) = sin(0.75πn)/(πn). What is h(0)? New 8-bit (byte) samples are read into a buffer where an address counter is increased
by one each time. When the counter has the value 0x03F F , the next value is
e) Modulo-N operation for number x is written here as < x >N . What is < −4 >3 ?
< 0x0400 >0x0400 = 0x0000. In other words, the oldest sample is replaced by the
f) What is the binary number (1001011)2 as a decimal number? newest.
f) The result depends on which number representation is chosen. In case of multi-byte
Solution: data types numbers can be saved in big-endian or little-endian manner. DSPs are
divided to fixed-point and floating-point processors (IEEE 754, sign bit, exponent
a) log8 7 = loge 7/ loge 8 = 1.9459/2.0794 = 0.9358. and mantissa fields). Least significant bit (LSB) is normally the last bit, most
Sometimes it is useful to convert, e.g., 22004 to decimal base: 22004 = 10x , taking log10 significant bit (MSB) leftmost. Negative numbers and fractions has to be considered,
on both sides: x = 2004 log10 2 = 603.2641, which finally gives 22004 = 1.837 · 10603 . too. Section 8.4 in Mitra deals with all aspects of the number representation.
b) Decibel scales are widely used to compare two quantities. The decibel difference When both negative and positive b-bit fraction values are needed, 1001011 is con-
between two power levels, ∆L, is defined in terms of their power ratio W2 /W1 (p. sidered to have a sign bit first, and then fraction bits, like s∆ a−1 a−2 . . . a−b . Table 6
99, Rossing et al., The Science of Sound, 3rd Edition, Addison Wesley) contains some possible results (see Table 8.1 at page 557 in Mitra) with values b = 6
and s = 1.
∆L = L2 − L1 = 10 log10 W2 /W1
non-negative fixed-point 1001011 1 · 64 + 1 · 8 + 1 · 2 + 1 · 1 = 75
P
Now the power (square) of signal is attenuated from 10 to 0.01, so the signal is sign-magnitude 1∆ 001011 (−2s + 1) bi=1 a−i 2−i = −11/64 ≈ −0.1719
P
attenuated by 30 dB: ones’ complement 1∆ 001011 −s · (1 − 2−b ) + bi=1 a−i 2−i = −52/64 ≈ −0.8125
P
two’s complement 1∆ 001011 −s + bi=1 a−i 2−i = −53/64 ≈ −0.8281
10 log10 (0.01/10) = 10 log10 10−3 = −30 offset binary 1∆ 001011 +11/64 ≈ +0.1719
In case of computing amplitude response |H(ejω )|, e.g. in Matlab directly from the
equation or with the command freqz, the values are squared for decibels Table 6: Problem 6: Examples on binary number representations with values b = 6 and s = 1.

2
10 log10 |(H/H0 )| = 20 log10 |(H/H0 )|

c) If Σ confuses, open the expression! There is hardly anything to draw!


+N
X
p(x) = kx = (−N )x + . . . + (−2)x + (−1)x + 0x + x + 2x + . . . + N x
k=−N

≡ 0, ∀N, x

d) Sinc-function is very useful in the signal processing, and it is defined sinc(x) =


sin(πx)/(πx). Also it is known that sin(x)/x → 1, when x → 0, and with sinc-
function sinc(0) = 1. Fourier-transform of a rectangular (box) signal produces spec-
trum with shape of sinc-function, and vice versa, a signal like sinc-function has a
spectrum of rectangular (box) shape.
Note that the result of the problem is not 1 nor 0,

h(n) = sin(0.75πn)/(πn) = 0.75 sin(0.75πn)/(0.75πn)


h(0) → 0.75

T-61.246 DSP 2005 31/140 SOLUTIONS T-61.246 DSP 2005 32/140 SOLUTIONS

7. Problem: 8. Problem: Examine a complex-valued function (z ∈ C)

a) Compute roots of H(z) = z 2 + 2z + 2. 1 + 0.5z −1 + 0.06z −2


H(z) =
b) Compute roots of H(z) = 1 + 16z −4 . 1 − 1.4z −1 + 0.48z −2
c) Compute long division (4z 4 − 8z 3 + 3z 2 − 4z + 6)/(2z − 3). (a) Multiply both sides by z 2 . (b) Solve z 2 +0.5z +0.06 = 0. (c) Solve z 2 −1.4z +0.48 = 0.
(d) H(z) can be written: H(z) = K · ((z − z1 ) · (z − z2 )) / ((z − p1 ) · (z − p2 )). What are
the five values? (e) What are the coefficients of H(z). What are the roots of H(z)? What
Solution: In this course roots of transfer function H(z) provide information on the
is the order of the numerator polynomial of H(z)? What is the order of the denominator
behaviour of the filter. The order of the rational polynomial H(z) = B(z)/A(z) is the
polynomial of H(z)?
maximum of the orders of B(z) and A(z).

a) The order of Solution: In this course complex-valued functions are widely used. In case of the transfer
√ H(z) is 2. Using the equation for solving the second-order polynomials
z = (−b ± b2 − 4ac)/(2a), the roots are z1 = −1 + j and z2 = −1 − j. This can be function H(z) both z and H(z) are complex-valued. A typical form of a transfer function
assured by multiplication (z − z1 )(z − z2 ) = z 2 − (z1 + z2 )z + z1 z2 = z 2 + 2z + 2. of a FIR filter is
H(z) = b0 + b1 z −1 + b2 z −2 + . . . + bM z −M
b) The order of H(z) is 4. Now, when setting H(z) = 1 + 16z −4 = 0, the √ equation can
be multiplied by z 4 on both sides. Hence, z√ 4
= 0 and z = 4 −16. Because
+ 16 √ and that of an IIR filter is
−16 = 24 · ej(π+2πk) , we get four roots using N z = | N r| · ej(2π k/N +θ/N ) .
b0 + b1 z −1 + b2 z −2 + . . . + bM z −M
Roots: zk = 2 ej(2πk/4+π/4) , with k = 0 . . . 3. Again, z14 = (2ejπ/4 )4 = 16ejπ = −16, H(z) =
1 + a1 z −1 + a2 z −2 + . . . + aN z −N
and similarly other zk result to −16.
c) Division operation can be applied to polynomials just as for normal numbers. Polyno- a) Multiplication H(z) · (z 2 /z 2 ) does not change the values of H(z), but it is more
mial product and division have a very close connection to the convolution operation. convenient to work with positive exponentials:
For example, in Matlab there is the same function conv for the both operations.
z 2 + 0.5z + 0.06
2z 3 − z 2 −2 H(z) =
 z 2 − 1.4z + 0.48
2z − 3 4z 4 − 8z 3 + 3z 2 − 4z + 6
− 4z 4 + 6z 3 b) Using the formula for second order polynomials az 2 + bz + c = 0
− 2z 3 + 3z 2 √
2z 3 − 3z 2 −b ± b2 − 4ac
z=
− 4z + 6 2a
4z − 6 we get easily the roots z1 = −0.3, z2 = −0.2. In Matlab you can write P = [1 0.5
0 0.06]; roots(P).
c) Similarly, the roots p1 = 0.8, p2 = 0.6.
d) Using the notation from (b) and (c),

(z + 0.3) · (z + 0.2)
H(z) = K ·
(z − 0.8) · (z − 0.6)
z 2 + 0.5z + 0.06
= K· 2
z − 1.4z + 0.48
we can scale H(z) correctly when K = 1.
e) In this case the coefficients were {1, 0.5, 0.06} in numerator polynomial (upper part),
and {1, −1.4, 0.48} in denominator polynomial (bottom part).
Roots were computed in (b) and (c). In DSP we call the roots of numerator poly-
nomial as “zeros”. The roots of denominator polynomial (bottom part) are “poles”.
As seen in (d) the same function H(z) can be expressed either using coefficients
or roots (and scaling factor). In the filter analysis the positions of roots give some
information on the nature of the filter. More about this in Problem 30.
T-61.246 DSP 2005 33/140 SOLUTIONS T-61.246 DSP 2005 34/140 SOLUTIONS

9. Problem: 10. Problem:


P∞
a) Decompose f (x) = 1/(x2 + 1) a) What is sum of series S = k=0 (0.5)
k
.
b) Decompose H(z) = (0.4 − 0.2z −1 )/(1 − 0.1z −1 − 0.06z −2 ) b) S =
P∞ k−2
k=10 (−0.6) .
P
c) S = ∞ k=2 (0.8
k−2
· e−jωk ).
Solution: In this course partial fractions are used when finding an explicit form of the
impulse response h[n] from the transfer function H(z). In the list of Fourier-transform
pairs there are only inverse transforms for the first order expressions. So, if the trans- Solution: Sum of geometric series is applied in Fourier- and Z-transforms.
P When the
fer function is of second-order or higher, it has to be converted to a sum of first-order ratio q in geometric series is |q| < 1, the sum of series converges to ∞ k
k=0 q = 1/(1 − q),
PN k
expressions by partial fraction decomposition (expansion). and correspondingly k=0 q = (1 − q N +1 )/(1 − q).
Decomposition requires taking roots of a polynomial, so it is possible to derive by hands a) Directly from the formula with q = 0.5, S = 1/(1 − 0.5) = 2.
only in some cases, e.g., 1/(x2 + 3x + 2) = 1/(x + 1) − 1/(x + 2). For more complicated
b) Open Σ expression if it seems to be difficult.
cases, see Mitra Sec. 3.9., or any other math reference. When using Matlab, the command
is residuez. ∞
X
Rules of thumb, (1) compute roots of the denominator polynomial, (2) write down the sum S = (−0.6)k−2 = (−0.6)8 + (−0.6)9 + (−0.6)10 + . . .
of first-order rational polynomials, (3) compute the unknown constants (equation pairs). k=10

Note that the decomposition in not unique, but there are several different expressions X
= (−0.6)k
which lead to the same result.
k=8
∞ 7
a) Find the roots of the denominator: x2 + 1 = 0 ⇒ x1 = −j, x2 = j. Roots can be X X
complex, too! Hence, = (−0.6)k − (−0.6)k
k=0 k=0
A B A B
f (x) = + = + = 1/(1 + 0.6) − (1 − (−0.6)8 )/(1 + 0.6) = (−0.6)8 /1.6 ≈ 0.0105
x − x1 x − x2 x+j x−j
A(x − j) + B(x + j) x(A + B) + j(−A + B) c) Discrete-time Fourier-transform is defined as
= =
x2 + jx − jx + 1 x2 + 1 ∞
X
( ( X(ejω ) = x[n]e−jωn
A+B =0 A = 0.5j
⇒ ⇒ n=−∞
−A + B = −j B = −0.5j
Finally, ∞
0.5j 0.5j X
f (x) = − S = (0.8k−2 · e−jωk ) |k = m + 2
x+j x−j
k=2
b) In this course z −1 corresponds a unit delay in time-domain. The numerator poly- X∞

nomial can divided and z −1 terms can be taken to front, and the partial fraction is = (0.8m · e−jωm · e−j2ω )
done only once for P (z), whose numerator polynomial is plain 1, m=0

X
0.4 − 0.2z −1 = e−j2ω · (0.8e−jω )m
H(z) =
1 − 0.1z −1 − 0.06z −2 m=0
1 1 1
= 0.4 · −1 −2
−0.2z −1 · −1 −2 = e−j2ω ·
|1 − 0.1z {z− 0.06z } |1 − 0.1z {z− 0.06z } 1 − 0.8e−jω
P (z) P (z)
The term e−j2ω can be seen as a time shift (delay) of two units.
The denominator of P (z) is set to zero and multiplied by z 2 : z 2 − 0.1z − 0.06 = 0.
The roots are z1 = 0.3 and z2 = −0.2.
A B A + 0.2Az −1 + B − 0.3Bz −1
P (z) = + =
1 − 0.3z −1 1 + 0.2z −1 1 − 0.1z −1 − 0.06z −2
( (
A+B =1 A = 0.6
Now we get a pair of equations ⇒ and finally,
0.2A − 0.3B = 0 B = 0.4
 0.6 0.4   0.6 0.4 
H(z) = 0.4 · + − 0.2z −1 · +
1 − 0.3z −1 1 + 0.2z −1 1 − 0.3z −1 1 + 0.2z −1

T-61.246 DSP 2005 35/140 SOLUTIONS T-61.246 DSP 2005 36/140 SOLUTIONS

11. Problem: 12. Problem: The unit impulse function δ[n] and the unit step function µ[n] (or u[n]) are
defined ( (
a) List all integral transforms that are used in previous signal processing courses. 1, when n = 0 1, when n ≥ 0
R4 δ[n] = µ[n] =
b) Compute the integral X(ω) = 0 e−jωt dt. 0, when n =
6 0 0, when n < 0
Sketch the following sequences around the origo
Solution: A general integral transform is defined by
a) x1 [n] = sin(0.1πn)
Z b
b) x2 [n] = sin(2πn)
F (ω) = f (t)K(ω, t)dt
a c) x3 [n] = δ[n − 1] + δ[n] + 2δ[n + 1]
where K(ω, t) is an integral kernel of the transform. d) x4 [n] = δ[−1] + δ[0] + 2δ[1]
e) x5 [n] = µ[n] − µ[n − 4]
a) In our case the time-domain signal is transformed to the frequency-domain in order
to improve the analyse. For example, the structure of a periodic signal can be seen f) x6 [n] = x3 [−n + 1]
easily in the spectrum.
Periodic signals can be represented as Fourier-series. Laplace- and Z-transforms Solution: There are different ways to draw discrete-time signals. Here we use “pins”
are more general than Fourier-transforms. There are versions for both analog and or “stems”, which emphasizes that the sequence is discrete-time. Compute the values for
digital signals as well as for one-dimensional and two-dimensional signals. Certain each n using sin(), δ[n], µ[n] functions, for example, in (c)
transforms are used in particular applications, say, discrete cosine transform is used
n δ[n − 1] δ[n] 2δ[n + 1] x[n]
in JPEG and wavelet transform in JPEG2000.
-2 δ[−2 − 1] = 0 δ[−2] = 0 2δ[−2 + 1] = 0 0+0+0=0
b) Now x(t) can be considered as a rectangular signal, and its Fourier transform is a -1 δ[−1 − 1] = 0 δ[−1] = 0 2δ[−1 + 1] = 2 0+0+2=2
sinc-function. 0 δ[0 − 1] = 0 δ[0] = 1 2δ[0 + 1] = 0 0+1+0=1
Z 4 4 1 δ[1 − 1] = 1 δ[1] = 0 2δ[1 + 1] = 0 1+0+0=1
e−jωt dt = (1/(−jω))e−jωt = (1/(−jω))(e−j4ω − 1)

X(ω) = 2 δ[2 − 1] = 0 δ[2] = 0 2δ[2 + 1] = 0 0+0+0=0
0 0

= (1/(−jω))(−e−j2ω )(ej2ω − e−j2ω ) = (1/(−jω))(−e−j2ω )(2j sin(2ω)) See the results in Figure 28. Note that in (b) the argument for the sine function is always
2π-multiple. In (d) there are only constants δ[−1] = δ[1] = 0 and δ[0] = 1 from the
= 4e−j2ω (sin(2ω)/(2ω)) = 4e−j2ω sinc(2ω/π) definition.
The discrete-time signal is purely a sequence of numbers, e.g. in (c), x3 [n] = {2, 1, 1},
where the underlined position is at n = 0.

(a) (b) (c)


1 1 2

0 0 1

0
−1 −1
−10 0
(d) 10 −5 0
(e) 5 −2 −1 (f)
0 1 2

2
1 1

0.5 0.5 1

0 0 0

−5−4−3−2−1 0 1 2 3 4 5 −3−2−1 0 1 2 3 4 5 −2 −1 0 1 2

Figure 28: Sequences of Problem 12. Top row: (a)-(c), bottom: (d)-(f).
T-61.246 DSP 2005 37/140 SOLUTIONS T-61.246 DSP 2005 38/140 SOLUTIONS

(a) vs (b): x(t) = 3cos(8π / 31 t) vs x[n] = 3cos(8π / 31 n)


13. Problem: Which of the following signals are periodic? Define the length of the funda-
mental period and frequency for periodic signals. 3 T=31/4
N=31

a) x(t) = 3 cos( 8π
31
t) 2

1
b) x[n] = 3 cos( 8π
31
n)
0
c) x(t) = cos( π8 t2 )
−1
d) x[n] = 2 cos( π6 n − π/8) + sin( π8 n)
−2
x(t)
e) x[n] = {. . . , 2, 0, 1, 2, 0, 1, 2, 0, 1, . . .} −3
x[n]
P
f) x[n] = +∞ k=−∞ δ[n − 4k] + δ[n − 4k − 1]
0 5 10 15 20
n, t
25 30 35

Figure 29: A visualization of the difference of fundamental periods of similar looking analog
and discrete-time signals in Problem 13(a) and (b). T0 = 31/4 but N0 = 31.
Solution: Continuous-time signal x(t) is periodic, if there exists period T ∈ R, for
which x(t) = x(t + T ), ∀t. The fundamental period is the smallest T0 > 0.
d) Periodic, N0 = 48. The fundamental period is the smallest common dividend for the
Discrete-time signal (sequence) x[n] is periodic, if there exists period N ∈ Z, for which
divisors in the periods, N1 = 12, N2 = 16 ⇒ N0 = 4N1 = 3N2 = 48. On the other
x[n] = x[n + N ], ∀n ∈ Z. The fundamental period is the smallest N0 > 0.
hand ω = 2π/N : ω1 = π/6, ω2 = π/8 ⇒ ω0 = π/24, ⇒ ω1 = 4ω0 , ω2 = 3ω0 .
The analysis is often done for sines or cosines which are 2π-periodic. Replace t by t + T
(n by n + N ) and try if the equation x(t) = x(t + T ) holds. Note that the amplitude π π 1 1
x[n] = 2 cos( n − π/8) + sin( n) = 2 cos(2π n − π/8) + sin(2π n)
or phase shift does not have effect on periodicity. The exponential function ejω is also 6 8 12 16
2π-periodic.
e) (Assume that) the period is N0 = 3, i.e. x[0] = x[±3k] = 2, x[1] = x[±3k + 1] = 0,
Another way to find the period of sine is to express the function in form of x(t) = x[2] = x[±3k + 2] = 1, where the integer k > 0.
sin(2π · f · t) where f is frequency (Ω = 2πf is angular frequency). Then T = 1/f .
f) N0 = 4. “Open” the sequence if you do not see it directly:
If there is a sum of cosines, like in (d), one has to find period T0 (N0 ), to which all periods
of individual cosines are multiples. Correspondingly, in frequency domain one has to find +∞
X
a fundamental frequency f0 , with which all individual frequencies can be represented. x[n] = δ[n − 4k] + δ[n − 4k − 1]
k=−∞
a) Periodic. When T = (31/4)k, then the original cosine argument is added 2π-multiple, = . . . + δ[n + 4] + δ[n + 4 − 1] + δ[0] + δ[n − 1] + δ[n − 4] + δ[n − 4 + 1] + . . .
and x(t) = x(t + T ) holds. The fundamental period is the shortest period T0 = 31/4. | {z } | {z } | {z }
k=−1 k=0 k=1

8π 8π 8π 8π = {. . . , 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, . . .}
x(t) = 3 cos( t) = 3 cos( (t + T )) = 3 cos( t + T )
31 31 31 31
8π 4 Periodicity of signal is often easy to see from the signal plot, see Figure 30. The signal (c)
= 3 cos( t + 2π( T )) is clearly not periodic. Real-life signals (e.g. speech signal) are seldom periodic in strict
31 31
sense; almost periodic signals are sometimes called “quasi-periodic”.
b) Periodic, N0 = (31/4) · k. The period N0 has to be integer, so the smallest possible
k = 4 gives the length of the fundamental period N0 = 31. 1
2 2
0.5
8π 8π 8π 8π

(a)

(b)

(c)
0 0 0
x[n] = 3 cos( n) = 3 cos( (n + N )) = 3 cos( n + N)
31 31 31 31 −0.5
−2 −2
8π 4 −1
= 3 cos( n + 2π( N ))
31 31 0 20 40 0 20 40 0 5 10

Notice also the difference of the results in (a) and (b), where x(t) = x(t + (31/4)), 1.5
2
but x[n] = x[n + 31]. The signals are plotted in the same axis in Figure 29. 2
1

(d)

(e)

(f)
c) Non-periodic, the latter term depends on t. The result can be also seen in Fig- 0 1
0.5
ure 30(c). −2 0 0
π π π π 0 20 40 60 80 −5 0 5 −5 0 5
x(t) = cos( t2 ) = cos( (t + T )2 ) = cos( t2 + (2tT + T 2 )) n n n
8 8 8 8 Figure 30: Signals and sequences in Problem 13, (a)..(c) in top row, (d)..(f) in bottom row. It
π 2 tT T2
= cos( t + 2π( + )) can be seen that (at least) (c) is not periodic in the scene shown.
8 8 16

T-61.246 DSP 2005 39/140 SOLUTIONS T-61.246 DSP 2005 40/140 SOLUTIONS

14. Problem: Express the input-output relations of the discrete-time systems in Figure 32. c) Input signal x[n] is multiplied by a sequence cos(ωn) (not a constant). This operation
is called modulation and is not LTI. The relation can be written as
Solution: In this problem there are several types of discrete-time systems. Notice that
y[n] = x[n] · cos(ωn)
the scope of this course is LTI systems (linear and time-invariant). LTI systems are very
easy to detect, they are relatively simple but very useful. In this course the system input
d) This is so called lattice structure (Mitra, Section 6). In order to get relationship
x[n] and output y[n] are 1-dimensional except some examples with pictures (2D). For
between x[n] and y[n] temporary variables are used after each summing unit. In this
LTI-systems the input-output relation can be written with a difference equation or a set
case, there is one temporary variable v[n], and the set of difference equations is
of difference equations.
There are some basic operations on sequences (signals) in discrete-time systems (x refers v[n] = x[n] + a v[n − 1]
to input to the system / operation, y output) shown also in Figure 31: y[n] = b v[n] + c v[n − 1]
• sum of signals (sequences) y[n] = x1 [n] + x2 [n] The temporary variable v[n] can be simplified away, but it is easier to determine the
• signal multiplication (by constant) y[n] = a x[n] transfer function H(z) in frequency domain, which is discussed later (Mitra, Section
• delay or advance of signal y[n] = x[n ± k] 3; “System analysis in Frequency Domain”). The simplified difference equation for
the system is y[n] = ay[n − 1] + bx[n] + cx[n − 1]. The system is LTI and IIR (see
• branch / pick-off node y1 [n] = x[n], y2 [n] = x[n] Problem 15).
• product of signals, modulator (non-LTI systems) y[n] = x1 [n] · x2 [n]
The discrete-time system does some computation for sequencies of numbers. Therefore it
x 1 [n] x[n] ax[n] x[n] x[n−1] is straightforward to write down a computer program, e.g. in (a),
D x[n]
a x[n]
x 2 [n] x 1 [n]+x 2 [n] x[n] x[n−1]
x1 := 0; x2 := 0;
z−1 x[n] while TRUE {
(a) (b) (c) (d) x2 := x1;
x1 := x0;
x0 := read_next_input(input_stream);
Figure 31: Problem 14: Basic operations in discrete-time systems, (a) sum of sequencies, (b) y := x0 - 2*x1 + x2;
amplification by constant, (c) unit delay (D, T , or z −1 ), and (d) branch / pick-off node. write_output(output_stream, y);
}
v[n]
x[n] +
x[n] y[n] x[n] y[n]
or if all samples are known and in a vector,
a b
D z−1 z−1 x[n] y[n]
−2 −2 2 for (k = 2; k <= length(x); k++) {
z−1
D
y[n] + D y[k] := x[k] - 2*x[k-1] + x[k-2];
cos( ω n)
c }
(a) (b) (c) (d)

Figure 32: Problem 14: Discrete-time systems, also at page 8.

a) Difference equation: y[n] = x[n] − 2x[n − 1] + x[n − 2]. LTI-filter, type FIR (see
Problem 15).
b) The memory registers / unit delays are often drawn either “D” (delay) or “z−1 (refers
to a delay in z-transform). Note that the output is fed back in the loop. The left
part of the filter is the same as (a). The sequence right after the second summing on
top line is y[n] which goes both to the output and down to feedback loop. Therefore
the terms coming into the last summing unit are x[n] − 2x[n − 1] + x[n − 2] from left
and 2y[n − 1] from the loop. The difference equation is

y[n] = 2y[n − 1] + x[n] − 2x[n − 1] + x[n − 2]

The system is LTI and type IIR (see Problem 15).


T-61.246 DSP 2005 41/140 SOLUTIONS T-61.246 DSP 2005 42/140 SOLUTIONS

15. Problem: Look at the flow (block) diagrams in Figure 33. 16. Problem: Determine if the system is (1) linear, (2) causal, (3) stable, and (4) shift-
x[n]
invariant.
-1

-1
-0.75
z
a) y[n] = x3 [n],
z v[n]
x[n] y[n] x[n] + P2
0.5 0.5 0.5
a
b) y[n] = γ + l=−2 x[n − l], γ is a nonzero constant,
b
x[n] y[n] y[n]
-1 -1 -1 0.75
x[n] 1/2 y[n] c) y[n] = αx[−n], α is a nonzero constant.
z z z
-0.75 0.5 -0.75 -1
z y[n] + D
1 c

i ii iii iv v Solution: Properties of the discrete-time system, see Mitra Sections 2.4.1, 2.5.3, and
Figure 33: Flow diagrams of Problem 15, also at page 7. 2.5.4.
a) What does LTI mean? How to prove or recognise LTI systems? Linearity:
b) Which systems are linear and time-invariant (LTI)? If y1 [n] and y2 [n] are the responses to the input sequences x1 [n] and x2 [n], respectively,
then for an input
c) Which systems have feedback?
x[n] = αx1 [n] + βx2 [n],
d) Which LTI systems are FIR and which are IIR?
the response is given by
y[n] = αy1 [n] + βy2 [n].
Solution: In this problem we try to recognise LTI systems by their layout.

a) LTI = linear AND time-invariant (=shift-invariant) system. These two properties x1


S
y
a
x1
a
y3* x3 y3
belong to a system not to a signal. Other system properties can be, e.g. stability, 1
S
causality, or if it needs memory or if it can be inverted. S b b
x2 y x2
See Problem 16 for mathematical proofs. 2

Recognition of LTI systems from the flow (block) diagrams: there are only (1) sums
of signals, (2) multiplication by a contant, (3) delays or advances. The components Figure 34: Linearity. If the linear combination of outputs of x1 and x2 is the same as the output
were introduced in Problem 14, see Figure 31 at page 39. of the linear combination of inputs, then the system is linear.
LTI systems can be represented with a linear constant coefficient difference (or dif- Causality:
ferential in case of analog system) equation
X X The n0 -th output sample y[n0 ] depends only on previous output values and input samples
dk y[n − k] = pk x[n − k] x[n] for n ≤ n0 , and does not depend on input samples for n > n0 . In case of LTI-system,
k k the system is causal if and only if impulse response h[n] = 0 for all n < 0.
where {dk } and Stability:
P{pk } are constants.POften in practice, we use causal finite-dimensional
LTI systems N k=0 dk y[n − k] =
M
k=0 pk x[n − k], where the order of the system is
Bounded input, bounded output (BIBO) stability: If a bounded input (Bx is a finite
given by max{N, M } (Mitra, Section 2.6). If the system cannot be written in the constant)
format above, it is not a (causal) LTI system. |x[n]| < Bx < ∞, ∀n
b) LTI? Only summing, delays, amplifications by constants. (i) Yes, (ii) Yes, (iii) Yes, produces a bounded output (By is a finite constant)
(iv) No, adding a constant, (v) Yes.
c) Feedback means that some of the output (or internal) values are fed back in the |y[n]| < By < ∞, ∀n
system. At that time the computation is recursive. There are loops in (i), (ii), (iii),
as a response then the system is BIBO stable (see (a) Pand (b) at Page 43 for details). In
and (v).
case of LTI-system, the system is stable if and only if ∞n=−∞ |h[n]| < ∞.
d) FIR = Finite (length) Impulse Response. IIR = Infinite (length) Impulse Response.
Time/Shift-invariance:
If the system has a feedback loop somewhere in the structure, it is also IIR at the
If y1 [n] is the response to an input x1 [n], then the response to an input
same time. The output value is computed using older output values, i.e. there is
recursion. This can be seen that there are also terms y[n−k], k 6= 0, in the difference x[n] = x1 [n − n0 ]
equation.
If there is no loop and computation flows forward all the time, then the system is is simply
FIR. This can be seen that there is only the term y[n] in the left side of the difference y[n] = y1 [n − n0 ],
equation above.
where n0 is any positive or negative integer.
FIR: (iv) has finite impulse response but it is not LTI. IIR: (i), (ii), (iii), and (v)
have infinite (length) impulse response because of feedback loops.

T-61.246 DSP 2005 43/140 SOLUTIONS T-61.246 DSP 2005 44/140 SOLUTIONS

c) y[n] = αx[−n], α is a nonzero constant.


Dk S
x1 x 2 = x 1 [n-k] y2 The system is linear, stable and noncausal.
Assume inputs x1 [n],x[n] and outputs y1 [n], y[n] , respectively, then
S Dk y[n] = αx[−n],
x1 y1 y 2* = y 1 [n-k]
y1 [n] = αx1 [−n].
Figure 35: Time invariance. If the output of delayed input is the same as delayed output, then
the system is time-invariant.
Let x[n] = x1 [n − n0 ], then

a) y[n] = x3 [n]. y[n] = αx[−n] = αx1 [−n − n0 ]


Take inputs x1 [n] and x2 [n], the outputs are then y1 [n] = x31 [n] and y2 [n] = x32 [n]. 6= αx1 [n0 − n] = αx1 [−(n − n0 )] = y1 [n − n0 ]
Now the linear combination of the input signals is x3 [n] = αx1 [n] + βx2 [n] and the
output is and the system is not time-invariant.
y3 [n] = (αx1 [n] + βx2 [n])3 6= αx31 [n] + βx32 [n] = αy1 [n] + βy2 [n].
Hence the system is not linear.
Since there is no output before the input hence the system is causal.
The system is stable: Assume |x[n]| < Bx , then
|y[n]| = |x3 [n]| ≤ |x[n]|3 < Bx3 = By < ∞.
The system is time-invariant: Assume input x1 [n] and output y1 [n], then response
of input x[n] = x1 [n − n0 ] is
y[n] = (x[n])3 = (x1 [n − n0 ])3 = y1 [n − n0 ]
P2
b) y[n] = γ + l=−2 x[n − l], γ is a nonzero constant.
Use linear combination αx1 [n] + βx2 [n] as the input
2
X
y3 [n] = γ + (αx1 [n − l] + βx2 [n − l])
l=−2
2
X 2
X
= 0.5γ + α x1 [n − l] + 0.5γ + β x2 [n − l]
l=−2 l=−2
2
X 2
X
6= αγ + α x1 [n − l] + βγ + β x2 [n − l]
l=−2 l=−2
= αy1 [n] + βy2 [n],
where α and β are not fixed. The system is hence nonlinear.
The system is not causal, because there can be output before input, when l ∈
[−2, −1].
System is stable: Assume bounded input |x[n]| < Bx , then
2
X 2
X
|y[n]| = |γ + x[n − l]| ≤ |γ| + |x[n − l]| < |γ| + 5Bx = By < ∞
l=−2 l=−2

The system is also time-invariant: Assume input x1 [n] and output y1 [n], then
response of input x[n] = x1 [n − n0 ] is
2
X
y[n] = γ + x1 [n − n0 ] = y1 [n − n0 ].
l=−2
T-61.246 DSP 2005 45/140 SOLUTIONS T-61.246 DSP 2005 46/140 SOLUTIONS

17. Problem: The impulse response can be expressed in a closed form from the transfer function
H(z) by inverse Z-transform (discussed later). However, the impulse reponse is the
a) What is the impulse response of the system in Figure 36(a)? What is the connection response for impulse, so just feed a delta function in and read what comes out. The
to the difference equation? Is this LTI system stable/causal? initial value y[−1] is by default zero.
b) What are the first five values of impulse response of the system in Figure 36(b)? n x[n] = δ[n] −2x[n − 1] x[n − 2] 2y[n − 1] y[n] = . . .
c) What are the first five values of impulse response of the system in Figure 36(d)? ... 0 0 0 0 0
-1 0 0 0 0 0
v[n] 0 1 0 0 0 1
x[n] y[n] x[n] y[n]
x[n] + 1 0 -2 0 2 0
D z−1 −1
z a b
2 0 0 1 0 1
3 0 0 0 2 2
−2 −2 2
4 0 0 0 4 4
D z−1
... 0 0 0 ... ...
y[n] + D
c The system is clearly causal but it seems not to be stable while the output is not
(a) (b) (d) bounded. The stability of IIR systems have to be checked every time, and there will
be easy tools for that later (poles of H(z) outside the unit circle).
Figure 36: Discrete-time systems for Problem 17, also at page 8. So, the first values of h[n] = {1, 0, 1, 2, 4, . . .} from which we can guess that the
closed form equation is h[n] = δ[n] + 2n−2 µ[n − 2].
Solution: Impulse response h[n] is the response of the system to the input δ[n]. LTI c) Now the difference equation is not so clear but a set of difference equations can be
discrete-time system is completely specified by its impulse response P
h[n] (Mitra 2.5.1). written easily,
For a LTI system (see Problems 15 and 16) the stability condition is n |h[n]| < ∞ and
the causability condition h[n] = 0, ∀n < 0. v[n] = x[n] + a v[n − 1]
y[n] = b v[n] + c v[n − 1]
If the impulse response h[n] is known for a LTI system, then the output y[n] can be
computed for any input x[n] by convolution.
Just like in (b), the columns for temporary values are computed, and finally the first
values of the impulse response are
Discrete-time
Impulse δ[n] −→ −→ Impulse response h[n]
(LTI) system h[n] = {b, ba + c, ba2 + ca, ba3 + ca2 , ba4 + ca3 , . . .}

from which it can be guessed that the closed form representation for the impulse
Discrete-time Output sequence y[n] response is h[n] = ban µ[n] + can−1 µ[n − 1].
Input sequence x[n] −→ −→
LTI system h[n] y[n] = h[n] ~ x[n]

a) h[n] = δ[n] − 2δ[n − 1] + δ[n − 2].


The length L{.} of the impulse response is finite, L{h[n]} = 3 < ∞. So, the filter is
FIR (finite impulse response).
Notice that in case of FIR filter (no feedbacks, flow always going forward), the
impulse response can be easily gotten from the corresponding difference equation
just by replacing y by h and each x by δ (Mitra 2.5.1). In this case the difference
equation is y[n] = x[n] − 2x[n − 1] + x[n − 2].
All FIR systems are always stable because the length ofP impulse response is finite,
and
P therefore also the sum of absolute values is finite: |h[n]| < ∞, in this case
|h[n]| = 1 + 2 + 1 = 4 < ∞.
This FIR system is causal while h[n] = 0 for all n < 0.
b) There is a feedback in the filter whose difference equation is

y[n] = 2y[n − 1] + x[n] − 2x[n − 1] + x[n − 2]

T-61.246 DSP 2005 47/140 SOLUTIONS T-61.246 DSP 2005 48/140 SOLUTIONS

18. Problem: So, the result is x[n] ~ h[n] = {1, 2, 1} = δ[n] + 2δ[n − 1] + δ[n − 2], and the length is
L{y[n]} = 3. The starting point can be checked: A{y[n]} = A{x[n]} + A{h[n]} = 0.
a) Compute x[n] ~ h[n], when
x[n] = δ[n] + δ[n − 1], and h[n] = δ[n] + δ[n − 1]. What is the length? b) Another way (on-line) is computing output values at each time moment n. Graphi-
cally this means inverting (flipping around) the other sequence, sliding it over the
b) Compute x1 [n] ~ x2 [n], when
other, and computing the output value as a dot sum (Mitra, Example 2.24).
x1 [n] = δ[n] + 5δ[n − 1], and x2 [n] = −δ[n − 1] + 2δ[n − 2] − δ[n − 3] − 5δ[n − 4].
What is the length? Where does the sequence start? Now when x1 [n] = δ[n]+5δ[n−1] and x2 [n] = −δ[n−1]+2δ[n−2]−δ[n−3]−5δ[n−4],
then L{x[n]} = 2 + 4 − 1 = 5 and A{x[n]} = 0 + 1 = 1. Therefore we know that the
c) Compute h[n] ~ x[n], when
convolution result is of form x[n] = a1 δ[n − 1] + a2 δ[n − 2] + a3 δ[n − 3] + a4 δ[n −
h[n] = 0.5n µ[n], and x[n] = δ[n] + 2δ[n − 1] − δ[n − 2]. What is the length?
4] + a5 δ[n − 5].

X
Solution: Linear convolution of two sequences h[n] and x[n]:
n=1: x[1] = x1 [k]x2 [1 − k]
X∞
k=−∞
y[n] = h[n] ~ x[n] = h[k]x[n − k]
= 0 + (x1 [0] · x2 [1 − 0]) + (x1 [1] · x2 [1 − 1]) + 0
k=−∞ | {z } | {z } | {z } | {z }
1 −1 5 0
The convolution is an operation for two sequences (or in continuous-time for two signals). = −1
There are several ways to get the convolution result. First, in (a) the convolution is

considered as filtering, the other sequence is the input and the other is the inpulse response X
n=2: x[2] = x1 [k]x2 [2 − k]
of the system, and the convolution result is the output of the system. Second, in (b) a
k=−∞
graphical way of inverting and sliding the sequences over each other is represented. In (c)
= 0 + (x1 [0] · x2 [2 − 0]) + (x1 [1] · x2 [2 − 1]) + 0
the convolution is considered as a sum of shifted and scaled sequences. However, even if
three ways are introduced separately, they all rely on the same (and simple) definition of = 2 + (−5) = −3
the convolution. ∞
X
When computing discrete-time convolution y[n] = x[n] ~ h[n], it is nice know a couple of n=3: x[3] = x1 [k]x2 [3 − k]
k=−∞
rules. Let L{.} be a length of a sequence, e.g. x[n] = {3, 2, 0, 5, −2}, then L{x[n]} = 5.
= 0 + (x1 [0] · x2 [3 − 0]) + (x1 [1] · x2 [3 − 1]) + 0
Because LTI-system is shift-invariant, the starting point of the convolution result can be
= −1 + 10 = 9
determined as a sum of starting points of the convolved sequencies. Let A{.} be an index
number of the first non-zero element, e.g. esim. A{x[n]} = −1. n=4: x[4] = −5 + (−5) = −10
It is easily seen that for the convolution result y[n] it holds
n=5: x[5] = −25
L{y[n]} = L{x[n]} + L{h[n]} − 1
A{y[n]} = A{x[n]} + A{h[n]}
The procedure is represented stepwise, and step n = 3 is shown also in Figure 37.
There are also some nice convolution demos in Internet: In the top line of the figure there is the sequence x1 [k] = {. . . , 0, 1, 5, 0, . . .}, in the
http://www.jhu.edu/~signals/convolve/index.html, Java applet second line the shifted and inverted sequence x2 [n − k]. It slides from left to right
http://www.jhu.edu/~signals/discreteconv2/index.html, Java applet when n increases, and at n = 3 it is x2 [3 − k] = {. . . , 0, −5, −1, 2, −1, 0, . . .}. The
http://www.csupomona.edu/~apfelzer/demos/convolution/ point-wise product of sequences in top rows is shown in the third line:
calculation/10-graphconvol.html, HTML {x1 [k]x2 [3 − k]} = {. . . , 0, 0 · (−5), 1 · (−1), 5 · 2, 0 · (−1), 0, . . .} = {−1, 10}.
The convolved
P value x[3] is the sum of values in the third row:
a) Consider convolution as filtering with the input sequence x[n] = δ[n] + δ[n − 1] = x[3] = ∞ k=−∞ x1 [k]x2 [3 − k] = −1 + 10 = 9.
{1, 1}, and the impulse response h[n] = δ[n] + δ[n − 1] = {1, 1}, of the system. In the bottom line there is the result for n ≤ 3, and n = 3 underlined, and results
The corresponding difference equation is y[n] = x[n] + x[n − 1], that is, the output for n > 3 are to be computed.
is just the sum of the present and previous value in the input. (You can draw the c) The convolution can be computed as a sum of shifted and scaled sequences.
flow (block) diagram for the system and verify the computation.) Now, h[n] = 0.5n µ[n], and x[n] = δ[n] + 2δ[n − 1] − δ[n − 2], in other words x[0] = 1,
n x[n] = δ[n] + δ[n − 1] x[n − 1] y[n] = x[n] + x[n − 1] x[1] = 2, x[2] = −1, and x[n] = 0, elsewhere. The division into three parts on
-1 0 0 0+0=0 third line emphasizes the fact that a scalar x[k] is zero with all values of k except
0 1 0 1+0=1 k = {0, 1, 2}.
1 1 1 1+1=2
2 0 1 0+1=1
3 0 0 0+0=0
4 0 0 0+0=0
T-61.246 DSP 2005 49/140 SOLUTIONS T-61.246 DSP 2005 50/140 SOLUTIONS

x[n]=x1[n] * x2[n], method "inverse&slide" y[n] = x[n] * h[n], method "scale&shift"

x[0] ⋅ h[n−0]
5 2 1 0.5 0.25 0.0625
1 0.125 0.03125

x [k]
0 0

1
0 1 5 0 −1
−5
−2 0 2 4 6
−4 −2 0 2 4

x[1] ⋅ h[n−1]
5 2

x [3−k]
0 −5 −1 −1 0 1
0 0
2
2
−1 0 2 1 0.5 ****
−5
−2 0 2 4 6
−4 −2 0 2 4

x[2] ⋅ h[n−2]
10 2
0 0 −1 −0.5 ****
Prod.

5 0 −1 0
1
0 0
−5 10 −1
−2 0 2 4 6
−4 −2 0 2 4
10

x[n] * h[n]
2
5 1
x[n]

0 0 0 0 −1 −3 0
0 1 2 0.25 0.125 * * * *
−5 9 −1
−2 0 2 4 6
−4 −2 0 2 4
Figure 37: Problem 18(b): Linear convolution using “invert and slide”. Caption from the step
n = 3, i.e. computing the value x[3] = 9. See the text for more details. There is a demo Matlab Figure 38: Problem 18(c): Linear convolution using “scaled and shifted sequences”. Top line:
program linconv.m to demonstrate the computation in the course web pages. x[0] · h[n − 0] = 0.5n µ[n], second: x[1] · h[n − 1] = 2 · 0.5n−1 µ[n − 1], third: x[2] · h[n − 2] =
−1 · 0.5n−2 µ[n − 2], bottom: convolution result, sum of sequences above.

19. Problem: Consider a LTI-system with impulse response h[n] = δ[n − 1] − δ[n − 2] and
y[n] = x[n] ~ h[n] input sequence x[n] = 2δ[n] + 3δ[n − 2].
X∞
= x[k]h[n − k] a) What is the length of convolution of h[n] and x[n] (without computing convolution
k=−∞ itself)? Which index n is the first one having a non-zero item?
−1
X 2
X ∞
X
= x[k]h[n − k] + x[k]h[n − k] + x[k]h[n − k] b) Compute convolution y[n] = h[n] ~ x[n]
k=−∞ k=0 k=3 c) Consider polynomials S(x) = 2 + 3x2 and T (x) = x − x2 . Compute the product
2
X U (x) = S(x) · T (x)
= 0+ x[k]h[n − k] + 0
d) Check the result by computing the polynomial division T (x) = U (x)/S(x).
k=0
= x[0] · h[n − 0] +x[1]h[n − 1] + x[2]h[n − 2]
|{z} | {z }
scaling shifted seq. Solution: An important rule of thumb for finding length L{.} of the linear convolution
= 1 · h[n] + 2 · h[n − 1] − 1 · h[n − 2] (different from circular convolution):
= 0.5n µ[n] + 2 · 0.5n−1 µ[n − 1] − 0.5n−2 µ[n − 2]
y[n] = h[n] ~ x[n] → L{y[n]} = L{h[n]} + L{x[n]} − 1
= δ[n] + 2.5δ[n − 1] + 0.5n µ[n − 2] | alternative
The first non-zero item A{.} for finite sequences:
It can be seen that values of x[n] were scaling factors and sequence h[n] was shifted
each time. While convolution is commutative (x1 [n] ~ x2 [n] = x2 [n] ~ x1 [n]), one can y[n] = h[n] ~ x[n] → A{y[n]} = A{h[n]} + A{x[n]}
compute the same using values of h[n] as scaling factors and shifting x[n]. The pro-
cedure is depicted in Figure 38. While the length of the other sequence is infinitive, a) L{h[n]} = 2, L{x[n]} = 3 → L{y[n]} = 4. Because h[n] is delayed by one
so is also the length of the convolution. (dh = +1) and x[n] starts from the origo (dx = 0), also their convolution is delayed
by one: A{h[n]} = 1, A{x[n]} = 0 → A{y[n]} = 1.
Now we know that the result is of form:

y[n] = a1 δ[n − 1] + a2 δ[n − 2] + a3 δ[n − 3] + a4 δ[n − 4]

T-61.246 DSP 2005 51/140 SOLUTIONS T-61.246 DSP 2005 52/140 SOLUTIONS

b) Using values of h[n] = δ[n − 1] − δ[n − 2] as scaling factors 20. Problem: The impulse response h1 [n] of a LTI system is known to be h1 [n] = µ[n] −
µ[n − 2]. It is connected in cascade (series) with another LTI system h2 as in Figure 5 at
y[n] = h[n] ~ x[n] page 9:

X h1 [n] → h2 [n] → h1 [n]
= h[k]x[n − k]
k=−∞ Compute the impulse response h2 [n], when it is known that the impulse response h[n] of
2
X the whole system is h[n] = {1, 5, 9, 7, 2} (Table 2 at page 9).
= h[k]x[n − k]
k=1 Solution: There are three subsystems connected in cascade (series). They are all linear
= 1 · (2δ[n − 1] + 3δ[n − 3]) − 1 · (2δ[n − 2] + 3δ[n − 4]) and time-invariant (LTI). The overall impulse response of the whole system is therefore
= 2δ[n − 1] − 2δ[n − 2] + 3δ[n − 3] − 3δ[n − 4]
h[n] = (h1 [n] ~ h2 [n]) ~ h1 [n]
c) U (x) = S(x) · T (x) = (2 + 3x2 ) · (x − x2 ) = 2x − 2x2 + 3x3 − 3x4 . Notice the h[n] = (h1 [n] ~ h1 [n]) ~ h2 [n]
correspondence with the result of (b), the delay is the power of x (z −1 in Z-transform). = δ[n] + 5δ[n − 1] + 9δ[n − 2] + 7δ[n − 3] + 2δ[n − 4]
d) Using long division (Mitra, Example 3.35). The polynomials are
U (x) = 2x − 2x2 + 3x3 − 3x4 and S(x) = 2 + 3x2 , Notice that h[n] and h1 [n] are known but h2 [n] is unknown. The operation, where h2 [n] is
computed, is called deconvolution. If polynomial products were used, then the operation
− x2 + x would be polynomial division H2 (x) = H(x)/(H1 (x)H1 (x)).

3x2 + 2 − 3x4 + 3x3 − 2x2 + 2x First, compute h11 [n] = h1 [n] ~ h1 [n], with h1 [n] = δ[n] + δ[n − 1],
3x4 + 2x2
3x3 + 2x h11 [n] = h1 [n] ~ h1 [n]
− 3x3 − 2x = δ[n] + 2δ[n − 1] + δ[n − 2]
0
Second, compute the length (here L{.}) of h2 [n]. While L{h[n]} = 5, L{h11 [n]} = 3, and
We get the result x − x2 as expected (h[n] = δ[n − 1] − δ[n − 2]). Convolution and
L{h[n]} = L{h11 [n]} + L{h2 [n]} − 1, the result is L{h2 [n]} = 3.
deconvolution operations can be computed using products and divisions of polyno-
mials. It is also possible to conclude that the non-zero values of h2 [n] are at n = 0, 1, 2. (Derive!)
Therefore the unknown sequence can be written as h2 [n] = aδ[n] + bδ[n − 1] + cδ[n − 2].
Third, compute the convolution, and solve the the unknown constants a, b, c.

h[n] = h11 [n] ~ h2 [n]


+∞
X 2
X
= h11 [k]h2 [n − k] = h11 [k]h2 [n − k]
k=−∞ k=0
= h2 [n − 0] + 2h2 [n − 1] + h2 [n − 2]
= (aδ[n] + bδ[n − 1] + cδ[n − 2])
+2(aδ[n − 1] + bδ[n − 2] + cδ[n − 3])
+(aδ[n − 2] + bδ[n − 3] + cδ[n − 4])
= aδ[n] + (b + 2a)δ[n − 1] + (c + 2b + a)δ[n − 2] + (2c + b)δ[n − 3] + cδ[n − 4]
= δ[n] + 5δ[n − 1] + 9δ[n − 2] + 7δ[n − 3] + 2δ[n − 4] | h[n] is known

The comparison between the last two lines from left gives a = 1, then (b + 2 · 1) = 5 ⇒
b = 3, then (c + 2 · 3 + 1) = 9 ⇒ c = 2, and also the rest values hold. In the end, the
result is
h2 [n] = δ[n] + 3δ[n − 1] + 2δ[n − 2]
which can be ensured by convolution.
T-61.246 DSP 2005 53/140 SOLUTIONS T-61.246 DSP 2005 54/140 SOLUTIONS

21. Problem: Determine the expression for the impulse response of each of the LTI systems 22. Problem: The impulse response of a digital matched filter, h[n], is the time-reversed
shown in Figure 39. replica of the signal to be detected. The time-shift is needed in order to get a causal
filter.
x[n] v[n] y[n] h4[n]
h1[n] h2[n]
The (binary) signal to be detected is given by s[n] = {1, 1, 1, −1, −1, 1, −1}. Consider an
v[n] y[n] input sequence x[n] which is a periodic sequence repeating s[n]. Determine h[n] and the
h1[n] h2[n] h3[n]
h5[n] x[n] result of filtering y[n] = h[n] ~ x[n].
h3[n] h4[n] h5[n]

(a) (b)
Solution: Matched filter (sovitettu suodin). Let s[n] be a (binary) 7-bit long codeword
to be detected, x[n] an input signal of repeated s[n], and the impulse response of the
Figure 39: LTI systems with variables x[n], v[n], y[n] in Problem 21. matched filter h[n] = s[−n]:

s[n] = {1, 1, 1, −1, −1, 1, −1}


x[n] = {. . . , s[n], s[n], s[n], . . .} =
Solution: All subsystems are LTI. Therefore we can use sum of impulse responses = {. . . , 1, 1, 1, −1, −1, 1, −1, 1, 1, 1, −1, −1, 1, −1, 1, 1, 1, −1, −1, 1, −1, . . .}
for parallel systems and convolution of impulse responses for cascade systems (Mitra, h[n] = s[−n] = {−1, 1, −1, −1, 1, 1, 1}
Example 2.27).
If any temporary variables are needed, they are probably best situated right after the The convolution result y[n] = h[n] ~ x[n] is shown in Figure 40.
summing units.
Problem 4. Output of the matched filter with input to be detected.
8
a) We can derive the impulse response h[n] of the whole system directly, or using a
temporary variable v[n] (easier!?) shown in Figure 39. The useful position for v[n] 6

is after summation.
4

v[n] = (h1 [n] ~ x[n]) + ((h3 [n] ~ h5 [n]) ~ x[n]) 2

y[n] = (h2 [n] ~ v[n]) + ((h3 [n] ~ h4 [n]) ~ x[n])


 0
= (h2 [n] ~ h1 [n]) + (h2 [n] ~ h3 [n] ~ h5 [n]) + (h3 [n] ~ h4 [n]) ~ x[n]
h[n] = (h2 [n] ~ h1 [n]) + (h2 [n] ~ h3 [n] ~ h5 [n]) + (h3 [n] ~ h4 [n]) −2
0 5 10 15 20 25

b) In the same way as in (a). Figure 40: Convolution result of the matched filter and desired sequence in Problem 22.
v[n] = (h4 [n] ~ x[n]) + ((h1 [n] ~ h2 [n]) ~ x[n]) The signal s[n] was chosen so, that the every seventh sample (length of s[n]) in output is
y[n] = (h3 [n] ~ v[n]) + ((h1 [n] ~ h5 [n]) ~ x[n]) high, and all others are low. If the signal s[n] were different, there would be not so clear

= (h3 [n] ~ h4 [n]) + (h1 [n] ~ h2 [n] ~ h3 [n]) + (h1 [n] ~ h5 [n]) ~ x[n] peaks in the convolution result.
h[n] = (h3 [n] ~ h4 [n]) + (h1 [n] ~ h2 [n] ~ h3 [n]) + (h1 [n] ~ h5 [n]) Note that convolution and cross-correlation have a close connection (Mitra, p. 89).

X
rxy [l] = y[n]x[−(l − n)] = y[l] ~ x[−l]
n=−∞

T-61.246 DSP 2005 55/140 SOLUTIONS T-61.246 DSP 2005 56/140 SOLUTIONS

23. Problem: Determine the autocorrelation sequence of the sequence 24. Problem: Sketch the following signals in time-domain and their (amplitude) spectra in
frequency-domain.
x1 [n] = αn µ[n], |α| < 1
a) x1 (t) = cos(2π 500 t)
and show that it is an even sequence. What is the location of the maximum value of the b) x2 (t) = 4 cos(2π 200 t) + 2 sin(2π 300 t)
autocorrelation sequence?
c) x3 (t) = e−j(2π 250t) + ej(2π 250t)
Solution: Cross-correlation sequence rxy [l] of two sequences and autocorrelation se- d) x4 (t) = x1 (t) + x2 (t) + x3 (t)
quence rxx [l] with lag l = 0, ±1, ±2, . . . are defined
∞ ∞
X X Solution: Fourier series / Continuous-time Fourier transform (CFT) / discrete-time
rxy [l] = x[n]y[n − l] rxx [l] = x[n]x[n − l] Fourier transform (DTFT) decomposes the signal to its frequency components. Cosine
n=−∞ n=−∞
and exponential function have a close relationship via Euler’s formula:

X cos(Ωt) = 0.5 · (ejΩt + e−jΩt )
rxx [l] = x1 [n]x1 [n − l]
n=−∞
Ideally, each real cosine component xi (t) = Ai cos(2πfi t + θi ) is a peak at frequency fi

X in an one-side spectrum or a peak pair at frequencies −fi and fi in a two-side spectrum.
= αn µ[n]αn−l µ[n − l]
n=−∞
So, if the signal x(t) (x[n]) is real-valued, then the two-side spectrum |X(jΩ)| (|X(ejω )|)

X is symmetric.
= α2n−l µ[n − l] The amplitude Ai expresses how strong the cosine component is.
n=0
( P∞
α2n−l = α−l
, for l < 0 a) A pure cosine at 500 Hz. Figure 42(a).
1−α2
= Pn=0
∞ −l −αl αl
2n−l α−l
− α1−α b) A sum of two cosines. Peaks at 200 and 300 Hz. Figure 42(b).
n=l α = 1−α2 2 = 1−α2
, for l ≥ 0
c) Two complex exponentials with the same amplitude and opposite frequencies can be
Note for the lag l ≥ 0, rxx [l] = αl
, and for l < 0, rxx [l] = α−l
. combined to a cosine using Euler’s formula. A peak at 250 Hz. Figure 42(c).
1−α2 1−α2
α−(−l) d) The sum signal contains all components in time domain as well as in frequency
Replacing l with −l in the second expression we get rxx [−l] = 1−α2
= rxx [l].
domain. Figure 42(d).
Hence, rxx [l] is an even function of l.
Maximum value of rxx [l] occurs at l = 0 since αl is a decaying function for increasing l Time Domain Freq. Domain
when |α| < 1. 4
5
(a)

0 2
Problem 3. Autocorrelation of x[n] = αn µ[n], α = 0.8

1
−5
0
0 0.005 0.01 0.015 0 200 400 600
x[n]

0.5
5 4
0
(b)

−2 0 2 4 6 8 10 12 14 0 2
1
−5
0
0 0.005 0.01 0.015 0 200 400 600
x[n−2]

0.5
5 4
l=2
0
(c)

−2 0 2 4 6 8 10 12 14 0 2
3 −5
0
2 0 0.005 0.01 0.015 0 200 400 600
r [2]
xx

1
5 4
(d)

0
−2 0 2 4 6 8 10 12 14 0 2
−5
0
Figure 41: Autocorrelation sequence in Problem 23. Top: x[n], middle: x[n − 2], bottom: 0 0.005 0.01 0.015 0 200 400 600
P time (s) freq. (Hz)
rxx [l], rxx [2] = k x[k]x[k − 2].
Figure 42: Signals and their one-side spectra (CFT) in Problem 24.
T-61.246 DSP 2005 57/140 SOLUTIONS T-61.246 DSP 2005 58/140 SOLUTIONS

Typically, when computing spectra numerically (x[n] instead of x(t)) with computer, the 25. Problem: Suppose that a real sequence x[n] and its discrete-time Fourier transform
peaks “spread”. There is the discrete Fourier transform (DFT) of signal x4 [n] ← x4 (t) in (DTFT) X(ejω ) are known. The sampling frequency is fs . At angular frequency ωc = π/4:
Figure 43, DFT using N=80 points in (a), and DFT using N=81 points in (b), and both X(ej(π/4) ) = 3 + 4j. Determine
having the sampling frequency fs = 2000. So, in (a) the resolution of the frequency is
exactly 25 Hz, whereas in (b) it is 2000/81 = 24.69 Hz. The components of the signal a) |X(ej(π/4) )| b) ∠X(ej(π/4) )
are multiples of 25 Hz (8 · 25 = 200, etc.) but not multiples of 24.69 Hz. This example is c) X(ej(−π/4) ) d) X(ej(π/4+2π) )
executed using the command fft in Matlab. e) If fs = 4000 Hz, what is fc

150 150
fs=2 kHz, N=80 fs=2 kHz, N=81 Solution: Discrete-time Fourier transform (DTFT) is always 2π-periodic:
res=25 Hz res=24.69 Hz

X ∞
X
100 100
X(ej(ω+2π) ) = x[n] e−j(ω+2π)n = x[n] e−jωn |e−j2π n jω
{z } = X(e )
n=−∞ n=−∞ =1
50 50
The value of DTFT was given at ωc = π/4 : X(ej(π/4) ) = 3 + 4j.

0 0 a) |X(ej(π/4) )| = 5
0 200 400 600 800 f (Hz) 0 200 400 600 800 f (Hz)
b) ∠X(ej(π/4) ) = arctan(4/3) ≈ 0.927
Figure 43: DFT of the same signal (now discrete-time x4 [n]) as in Figure 42(d): (a) signal c) X(ej(−π/4) ) = 3 − 4j
components are multiples of the frequency resolution, (b) not multiples. Actually there are
d) X(ej(π/4+2π) ) = 3 + 4j
only four frequency components in the signal, but this cannot be observed in (b). Example in
Problem 24. e) Angular sampling frequency is ωs = 2π. The interesting frequency can be obtained
from the ratio (ωc /ωs ) = (fc /fs ). If the sampling frequency fs = 4000 Hz, then
When analyzing spectra in any commercial software, the sequence is first “cut” with a 4000 Hz · (π/4)
window (Hamming, Hanning, Blackman, etc.). Windows and their effect on spectra are fc = = 500 Hz.

discussed later in FIR filter design.

T-61.246 DSP 2005 59/140 SOLUTIONS T-61.246 DSP 2005 60/140 SOLUTIONS

26. Problem: Compute DTFT for each of the following sequences using the definition. 27. Problem: The exponent term in DFT/IDFT is commonly written WN = e−j2π/N .

a) x1 [n] = δ[n − 2] a) Compute and draw in complex plane values of W3k


b) x2 [n] = 0.5n µ[n] b) Compute 3-DFT for the sequence x[n] = {1, 3, 2}.
c) x3 [n] = a[n] · cos( π5 n)
Solution: Discrete Fourier transform (DFT), left, and Inverse Fourier transform (DFT),
right, using N points are defined
Solution: Transforms of the sequences can be also read from the transform table.
However, this time transforms are computed from the definition. N −1 N −1
X 1 X j2π
Discrete-time Fourier transform (DTFT) of sequence x[n] is defined X[k] = x[n]WNkn x[n] = X[k]WN−kn , WN = e − N

n=0
N k=0

X
X(ejω ) = x[n]e−jωn a) WN = e−
j2π
N , now N = 3.
n=−∞
j2π
W30 = e− 3
·0
=1
a) x1 [n] = δ[n − 2] √
j2π 3
∞ ∞ W31 = e− 3
·1
= −0.5 − j
√2
X X
X1 (ejω ) = x1 [n]e−jωn = δ[n − 2]e−jωn j2π 3
n=−∞ n=−∞ W32 = e− 3
·2
= −0.5 + j
−j2ω
2
= e
−j 2 π / 3
Problem 3a. W3 = e
b) x2 [n] = 0.5n µ[n]
Notice that the exponent in W defines the angle jump 1
W2

X ∞
X in clockwise. What are the values of W3kn , when k = 3

X2 (ejω ) = x2 [n]e−jωn = 0.5n µ[n]e−jωn 0 . . . 2 and n = 0 . . . 2?. For example, k = 1, n = 2, 0.5


j2π
W03
n=−∞ n=−∞ we get W31·2 = W32 . Specially, W32·2 = W34 = e− 3 ·4 = 0
∞ j2π j2π
X e|−{z3 ·3} ·e− 3 ·1 = W31 .
= (0.5 · e−jω )n −0.5
=1
n=0 1
W3
1 k, n 0 1 2 −1
=
1 − 0.5 · e−jω 0 W30 W30 W30 −1 −0.5 0 0.5 1

1 W30 W31 W32


c) x3 [n] = a[n] cos( π5 n) 2 W30 W32 W31

X ∞
X π b) The sequence x[n] = {1, 3, 2} is of length 3.
X3 (ejω ) = x3 [n]e −jωn
= a[n] cos( n)e−jωn
n=−∞ n=−∞
5 2
X
∞ X[0] = x[n]W 0·n
X  −jωn
j π5 n −j π5 n n=0
= 0.5 a[n] e +e e
n=−∞
= 1+3+2=6
2
∞ X
x[n]W 1·n
X
= 0.5 a[n] e −j(ω− π5 )n
+e −j(ω+ π5 )n
 X[1] =
n=0
n=−∞
j(ω− π5 ) π  = 1 · W 0 + 3 · W√
1
+ 2 · W2
= 0.5 A(e ) + A(ej(ω+ 5 ) ) √ √
3 3 2 3 3
= 1 + (−1.5 − j) + (−1 + j) = −1.5 − j
2 2 2
X2
where A(ejω ) is DTFT of a[n]. Signal a[n] is modulated with ω = π/5. In the fre- X[2] = x[n]W 2·n
quency domain the spectrum A(ejω ) is “copied” (and scaled) at negative and positive n=0
angular frequency ω = π/5. = 1 · W 0 + 3 · W√
2
+ 2 · W4 √ √
3 3 2 3 3
= 1 + (−1.5 + j) + (−1 − j) = −1.5 + j
2 2 2
Notice that
T-61.246 DSP 2005 61/140 SOLUTIONS T-61.246 DSP 2005 62/140 SOLUTIONS

– DFT is discrete in frequency domain (DTFT is continuous) 28. Problem: Let g[n] and h[n] be two finite-length sequences given below:
– N-point DFT of a real signal is (very often) complex 
  −3, for n = 0,
– Each value of X[k] is a dot product of x[n] and W with some constant angle  5, for n = 0, 

4, for n = 1,
jump (nk) g[n] = 2, for n = 1, h[n] =
  0, for n = 2,
4, for n = 2 

– X[0] is the sum of values of x[n] (DC-component) 2, for n=3
– values of X[k] are N-periodic: X[k] = X[k + N ] = X[k + 2N ] = . . . a) Determine the linear convolution yL [n] = g[n] ~ h[n].
– absolute values (amplitude spectrum) are even |X[1]| = |X[−1]| b) Extend g[n] to length-4 sequence ge [n] by zero-padding and compute the circular
– angle values are odd ∠X[1] = −∠X[−1] convolution yC [n] = ge [n]
4 h[n].

DFT can be also calculated in matrix form as (Sec. 3.2.2 in Mitra) c) Explain the result! How the result of (b) can be used in overlap-save method when
the linear convolution of finite sequence and infinite sequence are computed.
X = DN x

where X is a column vector of the N frequency-domain DFT samples, x is a column Solution: In this problem linear convolution yL [n] (Mitra 2.5.1) and circular convolution
vector of N time-domain input samples, and DN is the N × N DFT matrix (dftmtx yC [n] (Mitra 3.4.1, 3.4.2, 3.6.1) are computed using sequences g[n] = {5, 2, 4} and h[n] =
in Matlab) {−3, 4, 0, 2}.
P
X = [X[0] X[1] . . . X[N − 1]]T a) Linear convolution: yL [n] = 2k=0 g[k]h[n−k]. Its length will be L{g[n]}+L{h[n]}−
x = [x[0] x[1] . . . x[N − 1]]T 1 = 6. Using “invert and slide”:
  yL [0] = g[0]h[0] = 5 · (−3) = −15
1 1 1 ... 1
yL [1] = g[0]h[1] + g[1]h[0] = 5 · 4 + 2 · (−3) = 14
1 WN1
 WN2 ... WNN −1 

1 W 2 4 2(N −1) yL [2] = g[0]h[2] + g[1]h[1] + g[2]h[0] = 5 · 0 + 2 · 4 + 4 · (−3) = −4
DN =  N W N ... WN 

 .. .. .. .. ..  yL [3] = g[0]h[3] + g[1]h[2] + g[2]h[1] = 5 · 2 + 2 · 0 + 4 · 4 = 26
. . . . . 
2(N −1) (N −1)(N −1) yL [4] = g[1]h[3] + g[2]h[2] = 2 · 2 + 4 · 0 = 4
1 WNN −1 WN . . . WN
yL [5] = g[2]h[3] = 4 · 2 = 8
−1
In the inverse DFT x = DN X the matrix D−1
N is Therefore, yL [n] = {−15, 14, −4, 26, 4, 8}.
 
1 1 1 ... 1
1 WN−1 WN−2 ... WN
−(N −1)  b) Circular convolution is computed in N = 4 points
1  −2(N −1)

3
DN =
1
 WN−2 WN−4 ... WN 
 X
N  .. .. .. .. ..  yC [n] = ge [n]
4 h[n] = ge [k]h[< n − k >4 ]
. . . . . 
k=0
−(N −1) −2(N −1) −(N −1)(N −1)
1 WN WN . . . WN
where ge [n] = {5, 2, 4, 0} is zero-extended version of g[n], and < n >4 is modulo-4
operation. Hence, h[< n − 5 >4 ] = h[< n − 1 >4 ], i.e. the sequence h[n] can be
It can be seen that D−1 ∗
N = (1/N )DN .
thought to be periodic with the period {h[0], h[1], h[2], h[3]}.
yC [0] = ge [0]h[< 0 − 0 >4 ] + ge [1]h[< 0 − 1 >4 ] +
ge [2]h[< 0 − 2 >4 ] + ge [3]h[< 0 − 3 >4 ]
= ge [0]h[0] + ge [1]h[3] + ge [2]h[2] + ge [3]h[1]
= 5 · (−3) + 2 · 2 + 4 · 0 + 0 · 4 = −11
yC [1] = ge [0]h[1] + ge [1]h[0] + ge [2]h[3] + ge [3]h[2]
= 5 · 4 + 2 · (−3) + 4 · 2 + 0 · 0 = 22
yC [2] = ge [0]h[2] + ge [1]h[1] + ge [2]h[0] + ge [3]h[3]
= 5 · 0 + 2 · 4 + 4 · (−3) + 0 · 2 = −4
yC [3] = ge [0]h[3] + ge [1]h[2] + ge [2]h[1] + ge [3]h[0]
= 5 · 2 + 2 · 0 + 4 · 4 + 0 · (−3) = 26
Thus, yC [n] = {−11, 22, −4, 26}.

T-61.246 DSP 2005 63/140 SOLUTIONS T-61.246 DSP 2005 64/140 SOLUTIONS

c) Now yL [n] 6= yC [n]. Linear and circular convolution would give the same result if 29. Problem:
length of circular convolution is that of linear convolution. However, in this problem w[n] y[n] y[n]

the length was only 4, not 6. x[n] y[n] y[n]


z −1 z −1
The convolution result can be utilized with overlap-add and overlap-save methods. 0.8 0.9 y[n−1]
Overlap-add and overlap-save methods are explained in Mitra, section 3.6.2 “Linear x[n−1]

Convolution of a Finite-Length Sequence with an Infinite-Length Sequence”. x[n] + 0.8 x[n−1] z−1
0.9 y[n−1] − 0.2 y[n−2] −0.2 y[n−2]

Circular convolution has a close connection to Discrete Fourier Transform (DFT).


Figure 44: LTI system of Problem 29, also at page 11. The difference equation can be written
easily using signals with small font.
yC [n] = ge [n]
4 h[n] DFT-4
−−−−→ Ge [k] · H[k] = YC [k] IDFT-4
−−−−−→ yC [n]
a) What is the difference equation of the system?
b) Compute X(z) from x[n] = (−0.8)n µ[n].
c) What is the transfer function H(z) = Y (z)/X(z)?
d) Compute y[n] using the convolution theorem.

Solution:
a) The input-output-relation is y[n] − 0.9y[n − 1] + 0.2y[n − 2] = x[n] + 0.8x[n − 1].
Notice that the coefficients in the diagram are also present in the difference equation
(past output values maybe as opposite numbers).
b) If computing using the definition, see Problem 26(b). From the z-transform table
directly:
1
Z{an µ[n]} =
1 − az −1
1
(−0.8)n µ[n] ↔
1 + 0.8z −1
−n0
c) Using the z-transform pair K · w[n − n0 ] ↔ K · z W (z):
y[n] − 0.9y[n − 1] + 0.2y[n − 2] = x[n] + 0.8x[n − 1] | z-transform
Y (z) − 0.9z −1 Y (z) + 0.2z −2 Y (z) = X(z) + 0.8z −1 X(z)
 
Y (z) 1 − 0.9z −1 + 0.2z −2 = X(z) 1 + 0.8z −1
1 + 0.8z −1
Y (z) = X(z) |/X(z)
1 − 0.9z −1 + 0.2z −2
1 + 0.8z −1
H(z) = Y (z)/X(z) =
1 − 0.9z −1 + 0.2z −2
The flow (block) diagram was given in direct form (Mitra 6.4.1). The coefficients of
the diagram are that of the difference equation and transfer function. Coefficients
in the loop (IIR subfilter) are in the denominator polynomial and coefficients of the
FIR part can be found in the numerator polynomial.
d) Using convolution theorem
Y (z) = H(z) · X(z)
1 + 0.8z −1 1
= ·
1 − 0.9z −1 + 0.2z −2 1 + 0.8z −1
1
= | partial fraction expansion
1 − 0.9z −1 + 0.2z −2
5 −4
= + | inverse z-transform
1 − 0.5z −1 1 − 0.4z −1
y[n] = 5 · (0.5)n µ[n] − 4 · (0.4)n µ[n]
T-61.246 DSP 2005 65/140 SOLUTIONS T-61.246 DSP 2005 66/140 SOLUTIONS

30. Problem: Consider the pole-zero plots in Figure 45. a) The order is the maximum of the number of poles or zeros (not in origo).
So, (i) 2 poles, 1 zero: 2nd order; (ii) 4 zeros: 4th order; (iii) 6 poles, 6 zeros: 6th
a) What is the order of each transfer function?
order.
b) Are they FIR or IIR? Note, in analog H(s) there are only poles, but in digital H(z) there can be both
c) Sketch the amplitude response for each filter. poles and zeros.
d) What could be the transfer function of each filter? b) If there is any pole (cross in the graph) outside the origo, it means that there is at
least first-order polynomial in the denominator in H(z) ⇔ there is a feedback in the
system ⇔ IIR.
1 1 1
Imaginary Part

Imaginary Part

Imaginary Part
Hence, (i) IIR; (ii) FIR; (iii) IIR.
4
0 0 0 c) The analysis with graphs is done below for each case separately.
Shortly, (i) lowpass with narrow passband; (ii) highpass; (iii) a comb filter.
−1 −1 −1
−1 0 1 −1 0 1 −1 0 1 d) The transfer function can be constructed from zeros zi and poles pi
Real Part Real Part Real Part
QM −1
Figure 45: Pole-zero plots of LTI systems in Problem 30, also at page 12. k=1 (1 − zk z )
H(z) = K · QN
−1
k=1 (1 − pk z )

Solution: However, the scaling factor cannot be seen from the pole-zero-plot.
The z-transform of the impulse response h[n] of the LTI system is the transfer function Next, a closer look at (c) is given for each filter.
H(z) (with certain ROCs). It can be written as a rational function in z −1 as follows
PM i) As a demo, some values of the amplitude response are computed. Then it will be
−k
B(z) b0 + b1 z −1 + b2 z −2 + . . . + bM z −M k=0 bk z shown that pretty good approximation can be fetched only by looking at zeros and
H(z) = = = PN
A(z) a0 + a1 z −1 + a2 z −2 + . . . + aN z −N k=0 ak z
−k poles of the filter. The actual transfer function is
QM −1
(1 − z1 z −1 ) · (1 − z2 z −1 ) · . . . · (1 − zM z −1 ) k=1 (1 − zk z ) H(z) = (1 + z −1 )/(1 − 1.79z −1 + 0.81z −2 )
= K · = K · QN
(1 − p1 z −1 ) · (1 − p2 z −1 ) · . . . · (1 − pN z −1 ) k=1 (1 − p k z −1 )
ω H(ejω ) |H(ejω )| ω H(ejω ) |H(ejω )|
where bi are the coefficients of the numerator polynomial B(z), and ai are the coefficients 0 1 1 3π/4 −.0008 + .0023j .0025
of the denominator polynomial A(z). The order of H(z) is max{M, N }. π/4 −.0277 + .0210j .0348 π 0 0
Those points zi where B(z) = 0 are called “zeros”, and points pi where A(z) = 0 are called π/2 −.0049 + .0061j .0078
“poles”. The figure with zeros (circles) and poles (crosses) plotted in the complex plane Now, without computing any exact values of the amplitude response (without know-
is called “pole-zero plot” (diagram) of the transfer function. ing H(z)), it is possible to approximate it by looking at the positions of zeros and
The rules of thumb for determining amplitude response from the pole-zero-diagram: poles. The angular frequency gets values from 0 to π, and the observation is done on
a unit circle counterclockwise. Poles are close to unit circle at ω = ±π/30. There-
1. Examine the frequencies ω ∈ (0..π), in other words, the observation point moves on fore the amplitude response gets the maximum approximately at that frequency and
the unit circle counterclockwise from (1, 0j) to (−1, 0j). In each point the amplitude the filter is lowpass type. The closer the poles are the unit circle, the narrower the
response |H(ejω )| is estimated. Remember that a simple function H(ejω ) has a maximum area is. The value at ω = π is zero.
smooth response.

|H (e )|
2. The amplification is big, when a pole is close to unit circle (a small factor in de- 1

nominator) or a zero is far from unit circle. The closer the pole is to unit circle, the 1 1

Imaginary Part
narrower the amplification is in frequency area. 0.5

3. The amplification is small, when a pole is far from the unit circle (big factors in 0 0.5

denominator) or there is a zero close to unit circle. −0.5


−1 0
4. The amplification is zero, if a zero is on the unit circle at observation frequency. −1 0 1 0 0.5 1
Real Part ω*π
5. Poles or zeros in the origo do not affect at all because the distance is always 1.

6. Normally |H(e )| is scaled so that the maximum value is set to be 1: Figure 46: Pole-zero-diagram and corresponding amplitude response |H1 (ejω )| in Problem 30(i).
|H(ejω )|
|H(ejω )|norm = max{|H(e jω )|}

T-61.246 DSP 2005 67/140 SOLUTIONS T-61.246 DSP 2005 68/140 SOLUTIONS

|H (ej ω)| length of a first order block in denominator polynomial:


Problem 2 (ii) 2

1 B B B
1 z }|1 { z }|2 { z M
}| {
Imaginary Part

QM
0.5 |(1 − z1 e−jω )| |(1 − z2 e−jω )| . . . |(1 − zM e−jω )| k=1 Bk
4 |H(ejω )| = K · = K · QN
0 0.5 |(1 − p1 e−jω )| |(1 − p2 e−jω )| . . . |(1 − pN e−jω )| k=1 Ak
−0.5
| {z } | {z } | {z }
A1 A2 AN
−1 0
−1 0 1 0 0.5 1
Real Part ω*π The frequency axis lies on the unit circle from ω = 0, which is a complex point ejω |ω=0 = 1
to ω = π, which is situated at ejω |ω=π = −1. The observation frequency ω0 gets values
Figure 47: Pole-zero-diagram and corresponding amplitude response |H2 (ejω )| in Problem 30(ii). 0 . . . π.
Bi is called a “zero vector”, i.e. it is the length from the observation point ω0 to zero i.
Ai is a “pole vector” correspondingly.
ii) Highpass (or bandstop) FIR filter. Notice that |H(ej0 )| 6= 0, because there is not a
zero on the unit circle. Actually, the minimum of |H(ejωmin )| ≈ 0.0114 (scaled) is at Any small Ai (pole close to unit circle) gives big value of |H(ejω )|. Any small Bi (zero
ωmin ≈ 0.11π (with H(z) = 1 − 3.753z −1 + 5.694z −2 − 3.753z −3 + z −4 ). close to unit circle) decreases |H(ejω )|. However, it should be noticed that |H(ejω )| is a
product of all zero vectors and all pole vectors.
iii) A (periodic) comb filter. Zeros are on the unit circle at uniform invervals.
For example, in Figure 49(a) M = 2 and N = 2:
|H3(ej ω)| B B
Problem 2 (iii) z }|1 { z }|2 {
1 1
jω |(1 − z1 e−jω )| |(1 − z2 e−jω )|
|H(e )| = K ·
Imaginary Part

−jω −jω
0.5 |(1 − p1 e )| |(1 − p2 e )|
| {z } | {z }
0 0.5 A1 A2
−0.5
−1 0
It can be roughly estimated that the filter is highpass, because around ω = 5π/6 A1
−1 0 1 0 0.5 1 is smallest and therefore |H(ejω )| is at maximum. Actually the maximum might be at
Real Part ω*π ω = π, where A1 · A2 is probably smaller. The rough estimate of the amplitude response
(0 . . . ω0 . . . π) is given in Figure 49(b).
Figure 48: Pole-zero plot and corresponding amplitude response |H3 (ejω )| in Problem 30(iii).
π /2 ω0
z = e jω
B1
Determining amplitude response from the pole-zero-diagram, theory in back-
A1 |H(e^j ω )|
ground. Any transfer function H(z) can be expressed in form of B2 1
π ω =0
A2
|p0 | (1 − z1 z −1 )(1 − z2 z −1 )...(1 − zM z −1 )
H(z) =
|d0 | (1 − p1 z −1 )(1 − p2 z −1 )...(1 − pN z −1 )
0
In order to achieve this, all zeros (zi ) and poles (pi ) of H(z) has to be computed. Zeros ω0
are the roots of the numerator polynomial and poles are the roots of the denominator 0 π /2 π

polynomial. Numerator part is “FIR part” (always stable, y[n] depends only on values of (a) (b)
x[n − ki ]), denominator is “IIR part” (feedback, in order to compute y[n] some old values Figure 49: (a) Zero vectors Bk and pole vectors Ak . ω runs 0..π. (b) Amplitude response
of it has to be used). roughly from the pole-zero-diagram.
Frequency response is the transfer function computed on unit circle, i.e. substitution
z = ejω :
|p0 | (1 − z1 e−jω )(1 − z2 e−jω )...(1 − zM e−jω ) The rules of thumb were given in Page 65.
H(ejω ) =
|d0 | (1 − p1 e−jω )(1 − p2 e−jω )...(1 − pN e−jω ) It can also be seen that the frequency response in discrete-time domain is always 2π-
We are interested in amplitude response |H(ejω )|. Because the expression is in a product periodic. Because |H(ejω )| is an even function, it is only necessary to draw angles 0 . . . π.
form, the absolute value of |H(ejω )| can be computed with its first order blocks. Let
K = |p0 |/|d0 |, Bi be the length of a first order block in numerator polynomial, and Ai the
T-61.246 DSP 2005 69/140 SOLUTIONS T-61.246 DSP 2005 70/140 SOLUTIONS

Problem 4. Pole−zero−diagram
31. Problem: Consider the filter described in Figure 50. 1

0.8

x[n] y[n] 0.6

0.4

Imaginary Part
0.2

0
Z-1 Z-1
−0.2
−0.4

−0.6
-1 -1
Z Z −0.8
−1
−1 −0.5 0 0.5 1
-1 -0.81 Real Part

Figure 50: LTI system of Problem 31, also at page 12.


Figure 51: Pole-zero plot of H(z) in Problem 31.

a) Derive the difference equation of the system.


b) Calculate the transfer function H(z). The system is causal, because current output does not depend on future values
of x[n] and y[n] (time-domain view). The system is stable, because the impulse
c) Calculate the zeros and poles of H(z). Sketch the pole-zero plot. Is the system response h[n] is absolutely summable (time-domain view).
stable and/or causal?
On the other hand, if all poles in the pole-zero plot are inside the unit circle, i.e.,
d) Derive frequency response H(ejω ). the region of convergence (ROC) includes both the unit circle and the infinity, the
e) Sketch the magnitude (amplitude) response |H(ejω )| roughly. Which frequency gives filter is causal and stable (see Problem 32).
the maximum value of |H(ejω )|? d) Frequency response of the system H(ejω ) (often for continuous systems H(ω)) is
f) Compute the equation for the impulse response h[n] using partial fraction expansion obtained by applying z = ejω (continuous s = jω). If the unit circle is contained in
and inverse z-transform. the ROC, it is possible to apply H(ejω ) = H(z)|z=ejω :

1 − e−2jω
Solution: Notice that the same filter can be represented (i) as a block diagram, (ii) H(ejω ) =
1 + 0.81e−2jω
with a difference equation, (iii) with a transfer function (and ROC), (iv) with an impulse
response, (v) with poles, zeros and gain. e) The amplitude response can be computed as exact as wanted using the mathematical
functions. It can be computed also in specific points using calculator or computer.
a) Difference equation: y[n] = x[n] − x[n − 2] − 0.81y[n − 2] These will be explained after the roughest way, which is graphical approximation
b) Transfer function H(z) can be obtained from h[n] using z-transform pairs: from poles and zeros.
The sketch the magnitude (amplitude) response |H(ejω )| can be drawn by using
Z{x[n]} = X(z) pole-zero plot. There are zeros at z = 1 and z = −1. The corresponding angular
Z{x[n − n0 ]} = z −n0 X(z) frequencies are 0 and π, because ej0 = 1 + 0j and ejπ = −1 + 0j. Hence, amplitude
Z{ax[n]} = aX(z). response is zero when ω = 0 and ω = π. It is also clear that the maximum value is at
ω = π/2, where the pole is closest to the unit circle. A sketch is given in Figure 52.
Hence,
|H(e^jw)|
y[n] = x[n] − x[n − 2] − 0.81y[n − 2]
Y (z) = X(z) − z −2 X(z) − 0.81z −2 Y (z) 1
(1 + 0.81z ) · Y (z) = (1 − z −2 ) · X(z)
−2

1 − z −2
Y (z) = X(z) ·
1 + 0.81z −2
Y (z) 1−z −2 0
H(z) = =
X(z) 1 + 0.81z −2 π/2 π

c) Zeros are the points, where the numerator of transfer function H(z) is zero: Figure 52: A rough sketch of amplitude response using pole-zero plot in Problem 31(e).
1 − z −2 = 0 ⇔ z 2 = 1 ⇔ z = ±1.
Second, the amplitude response H(ejω ) = (1 − e−2jω )/(1 + 0.81e−2jω ) can be cal-
Poles are the points, where the denominator of transfer function H(z) is zero:
culated in certain poins. More points, more exact amplitude response. Start with
1 + 0.81z −2 = 0 ⇔ z 2 = −0.81 ⇔ z = ±0.9j
points ω = {0, π/4, π/2, 3π/4, π}, and calculate more if it seems to be appropriate. If
The pole-zero plot of the system is (a common notation is to use a for a zero and your calculator does not support complex exponentials, decompose them by Euler’s
a × for a pole) in Figure 51.

T-61.246 DSP 2005 71/140 SOLUTIONS T-61.246 DSP 2005 72/140 SOLUTIONS

formula. (Notice that in Matlab you can use directly function exp.) A new sketch 32. Problem: The transfer function of a filter is
is drawn in Figure 53.
1 − z −1
ω H(ejω ) |H(ejω )| ω H(e ) jω jω
|H(e )| H(z) =
1 − 2z −1 + 0.75z −2
0 0 0 5π/8 0.6352 + 2.5067 2.5859
π/8 0.0199 − 0.4568j 0.4573 3π/4 0.1147 + 1.0929j 1.0989 a) Compute the zeros and poles of H(z).
π/4 0.1147 − 1.0929j 1.0989 7π/8 0.0199 + 0.4568j 0.4573 b) What are the three different regions of convergence (ROC)?
3π/8 0.6352 − 2.5067j 2.5859 π 0 0
c) Determine the ROC and the impulse response h[n] so that the filter is causal.
π/2 10.5263 − 0.0000j 10.5263
d) Determine the ROC and the impulse response h[n] so that the filter is stable.
|H(e^jw)|
Solution: Let us begin by reviewing some properties we need in this exercise:
10.53
– The filter is causal ⇔ ∞ belongs to the region of convergence.
– The filter is stable ⇔ H(z) converges on the unit circle.
0 – The region of convergence on z-plane must not contain any poles; it may be a ring
between two poles, the disc limited by the closest pole to origin or the plane outside
π/2 π the most distant pole from origin.
Figure 53: A sketch of amplitude response after computing several values in Problem 31(e). – It is easiest to do the the inverse z-transform (here) by calculating first the fractional
expansion of the H(z) and then inverting each part of it individually using the sum
Third, the magnitude response can (only sometimes) be simplified. For example, this of a geometric series.
time the simplified version is relatively simple. Simplification is sometimes needed
– The sum of a geometric series is
to some proofs, etc.

jω 2 jω ? jω jω −jω
X 1
|H(e )| = H(e )H (e ) = H(e )H(e ) | complex conjugate qk = , |q| < 1
1−q
1 − e−2jω 1 − e+2jω k=0
= ·
1 + 0.81e−2jω 1 + 0.81e+2jω
– The z-transform of h[n] is
1 + 1 − (e + e−2jω )
2jω

= X
1 + 0.812 + 0.81(e2jω + e−2jω ) h[n]z −k
2 − 2 cos(2ω) n=−∞
= | square
1.6561 + 1.62 cos(2ω)
a) First we have to solve the poles and zeros:
|H(ejω )| gets the maximum value at frequency ω = π2 . The maximum value is
1 − z −1 z(z − 1)
H(z) = = 2
π
|H(ejω )|max = H(ej 2 ) ≈ 10.5 1 − 2z −1 + 0.75z −2 z − 2z + 0.75
Poles:
f) Notice that the partial fraction expansion can be written in various forms. For √
example, Matlab (residuez) gives the different form than the following: 2± 4 − 4 · 0.75
z 2 − 2z + 0.75 = 0 ⇔ z = ⇔ z1 = 0.5, z2 = 1.5
2
1 − z −2
H(z) = Zeros:
1 + 0.81z −2
1 1 z(z − 1) = 0 ⇔ z1 = 0, z2 = 1
= − z −2 · | part. frac. exp.
1 + 0.81z −2 1 + 0.81z −2 b) Now we may answer to the questions about stability and causality using different
= ... ROCs, see Figure 54:
h[n] = 0.5 · ((0.9j)n µ[n] + (−0.9j)n µ[n]) + i) If we require causality, the region of convergence has to include z = ∞ Thus,
0.5 · (0.9j)n−2 µ[n − 2] + (−0.9j)n−2 µ[n − 2]
 the region of convergence has to be ”outside” the pole z = 1.5, that is |z| > 1.5.
ii) If we require stability, the unit circle has to be on the region of convergence.
≈ {1.0000, 0, −1.8100, 0, 1.4661, 0, −1.1875, . . .}
Thus the region is a ring between the poles: 0.5 < |z| < 1.5
iii) If ROC is the inner cicle |z| < 0.5, we will have a noncausal and astable filter.
T-61.246 DSP 2005 73/140 SOLUTIONS T-61.246 DSP 2005 74/140 SOLUTIONS

ROC: |z| > 1.5 ⇔ CAUSAL, NOT STABLE → h[n] = 0.5 . 0.5n µ[n] + 0.5 . 1.5n µ[n]

Im Im 6

Re Re 0
−2 −1 0 1 2 3 4 5 6

Figure 55: ROC: |z| > 1.5 ⇔ Filter is causal but not stable. The impulse response is
hcausal [n] = 0.5 · 0.5n µ[n] + 0.5 · 1.5n µ[n]. The
P impulse response grows to infinity and it is
therefore not absolutely summable (criterion n |h[n]| < ∞). Problem 32(c).

Figure 54: Region of convergence (ROC) in gray in Problem 32: (i) ∞ belongs to ROC - causal P
d) Stable filter ⇒ we know that 0.5 < |z| < 1.5. We note that ∞ n −n
n=0 1.5 z does not
filter, (ii) unit circle belongs to ROC - stable filter.
converge as | 1.5
z
| ≥ 1. We have to convert the expression to higher terms in order to
get the denominator to suitable form:
Note, that in this case we cannot have a filter that is both causal and stable.
At this point, when we calculate the impulse response h[n], we have to do an inverse 1 1
Hp2 (z) = · | · (−(2/3)z)/(−(2/3)z)
z-transformation for the transfer function H(z). To do this we express the H(z) 2 1 − (3/2)z −1
as a partial fraction expansion as then we may apply the formula of the sum of a
geometric series. 1 1
= − z
Using the poles and zeros we may write the transfer function as follows: 3 1 − (2/3)z
∞  n
(1 − z1 z −1 )(1 − z2 z −1 ) 1 − z −1 1 X 2
H(z) = = = − z zn
(1 − p1 z −1 )(1 − p2 z −1 ) (1 − 0.5z −1 )(1 − 1.5z −1 ) 3 n=0 3
∞  n
A B 1 X 2
⇔ H(z) = + = − µ[n]z n+1 | let −m = n + 1
1 − 0.5z −1 1 − 1.5z −1 3 n=−∞ 3
⇔ 1 − z −1 ≡ A(1 − 1.5z ) + B(1 − 0.5z −1 )
−1

∞  −m−1
We solve A and B by letting z → 0.5 and z → 1.5 1 X 2
= − µ[−m − 1]z −m
3 m=−∞ 3
z → 0.5 : 1 − 0.5−1 = A(1 − 1.5 · 0.5−1 ) + B(1| − 0.5{z· 0.5−1})
=0
⇒ A = 0.5 Thus, the inverse transform of H(z) (see Figure 56) is
 −n−1
z → 1.5 : 1 − 1.5−1 = A(1| − 1.5{z· 1.5−1}) + B(1 − 0.5 · 1.5−1 ) 1 2
hstable [n] = 0.5 · 0.5n µ[n] − µ[−n − 1]
=0 3 3
⇒ B = 0.5
n −n−1
ROC: 0.5 < |z| < 1.5 ⇔ NOT CAUSAL, STABLE → h[n] = 0.5 . 0.5 µ[n] + 1/3 . (2/3) µ[−n−1]

Now we may write the expansion 0.8

0.6

0.5 0.5 0.4

H(z) = +
1 − 0.5z −1 1 − 1.5z −1 0.2

c) Causal filter ⇒ we know that |z| > 1.5. We notice that both fractions in −0.2

−0.4

0.5 0.5
H(z) = + −4 −3 −2 −1 0 1 2 3 4

1 − 0.5z −1 1 − 1.5z −1
−1 −1
represent a sum of a geometric series, as |0.5z | < 1 and |1.5z | < 1 as required. Figure 56: ROC: 0.5 < |z| < 1.5 ⇔ Filter is not causal but stable. The impulse response is
We conclude (see Figure 55): hstable [n] = 0.5 · 0.5n µ[n] + 31 · ( 32 )−n−1 µ[−n − 1]. The impulse response is non-zero for indices
n < 0 (criterion h[n] < 0, n < 0). Problem 32(d).
hcausal [n] = Z −1 {H(z)} = 0.5 · 0.5n µ[n] + 0.5 · 1.5n µ[n]

T-61.246 DSP 2005 75/140 SOLUTIONS T-61.246 DSP 2005 76/140 SOLUTIONS

33. Problem: Examine the following five filters and connect them at least to one of the 4
1 0
2
following categories (a) zero-phase, (b) linear-phase, (c) allpass, (d) minimum-phase, (e) 2 0.5
−20
maximum-phase. 0 0
8
0

−0.5 −40
h1 [n] = −δ[n + 1] + 2δ[n] − δ[n − 1] −2
−2
−1
−4 −60
1 + 3z −1 + 2.5z −2 −4 −2 0 2 4 −1 0 1 0 pi/2 pi 0 pi/2 pi

H2 (z) = (i) (ii) (iii) (iv)


1 − 0.5z −1
y3 [n] = 0.5y3 [n − 1] + x[n] + 1.2x[n − 1] + 0.4x[n − 2] Figure 57: An example of a zero-phase transfer function in Problem 33. Subfigures (for Fig-
0.2 − 0.5z −1 + z −2 ures 57..62), (i) impulse response h[n], (ii) pole-zero plot, (iii) amplitude response |H(ejω )|,
H4 (z) = x-axis (0 . . . π), (iv) phase response ∠H(ejω ), x-axis (0 . . . π).
1 − 0.5z −1 + 0.2z −2
H5 (ejω ) = −1 + 2e−jω − e−2jω
H2) When all zeros are outside the unit circle, the filter has maximum phase. The
filter is IIR, the two zeros are outside the unit circle. When plotting the amplitude
Solution: Types of transfer functions are explained in Mitra 4.4. After some work at response, it can be noticed that the filter is lowpass (LP). The filter H2 (z) is at least
least the following pairs can be mentioned: (a) h1 [n], (b) H5 (ejω ), (c) H4 (ejω ), (d) y3 [n], maximum-phase.
and (e) H2 (z).
Another example on a maximum-phase transfer function (Mitra 4.7), whose all zeros
If the coefficients of the transfer function are real-valued (as they are in this course), then lie outside the unit circle in Figure 58
the pole and zero pairs must be complex conjugates: z1 = rejθ , z2 = re−jθ .
If the coefficients of the FIR filter are symmetric (Type I, II, III, IV; Sections 4.4.3 and 1 − 2.773z −1 + 3.108z −2 − 3.125z −3
H(z) =
4.4.4 and Figures 4.14 and 4.16), then the filter has linear phase response (or even zero- 1 + 1.559z −1 + 0.81z −2
phase). The group delay (τ (ω) = −d/dω ∠H(ejω )) of linear-phase filters is constant for
all frequencies. 15
10 1 0 2
Another important term is mirror-symmetry respect to the unit circle. In this case the 5 0.5 0
connection between poles or zeros is: z1 = rejθ , z2 = (1/r)ejθ (and their complex conju- 0 cont. 0
−20
−2
gates). −5 −0.5 −40 −4
−10 −1
For each filter type there is also another example. There are four figures a row for each −15
0 5 10 −1 0 1 2 −60
0 pi/2 pi
−6
0 pi/2 pi
example, (i) impulse response, (ii) pole-zero-diagram, (iii) amplitude response in desibels
(i) (ii) (iii) (iv)
and x-axis in range 0 . . . π, (iv) phase response.
Figure 58: An example of a maximum-phase transfer function in Problem 33.
h1) This noncausal FIR filter has zero phase. The impulse response h1 = −δ[n + 1] +
2δ[n] − δ[n − 1] is symmetric around the origo in the time-domain. The frequency
response can be written y3) When all zeros are inside the unit circle, the filter has minimum phase. From the
difference equation we get
H1 (ejω ) = −ejω + 2 − e−jω = 2 − 2 cos(ω)
|H1 (ejω )| = |2 − 2 cos(ω)| ≥ 0 | ampl.resp. ∈ R 1 + 1.2z −1 + 0.4z −2
H3 (z) =
∠H1 (ejω ) = 0 | phase resp. 1 − 0.5z −1
d
− ∠H1 (ejω ) = 0 | no delay at all The transfer function is similar to H2 (z), but the zeros are now mirror-symmetric to
dω those. Therefore the amplitude response is the same, but the filter is minimum-phase
from which it can be seen that H1 (ejω ) is real-valued. The phase response and group (Mitra 4.7).
delay (τ (ω) = −d/dω ∠H(ejω )) is therefore zero (or 180 degrees for negative values Another example on a minimum-phase transfer function whose all zeros lie inside
of H(ejω )) for all frequencies, in other words, the filter is zero-phase (Mitra 4.4.2), the unit circle in Figure 59
and the signal is not delayed in the filter. Matlab command filtfilt can be applied
instead of filter. 1 − 0.9944z −1 + 0.8872z −2 − 0.32z −3
H(z) =
Another example, see Figure 57. The zeros are situated mirror-symmetrically ac- 1 + 1.559z −1 + 0.81z −2
cording to the unit circle, and the impulse response and the transfer function are
A minimum-phase transfer function can be converted to a maximum-phase transfer
h[n] = {1, 3.2893, 3.8875, 0.0884, −3.0407, 0.0884, 3.8875, 3.2893, 1} function (or vice versa) by mirroring the zeros respect to the unit circle. This can
X
H(z) = h[n]z −n be done using an appropriate allpass function.
n
T-61.246 DSP 2005 77/140 SOLUTIONS T-61.246 DSP 2005 78/140 SOLUTIONS

6
1 1 1
4 1 0 LP
2 HP
0.8
2 0.5 0.5 0.5
−20 0.6
0 cont. 0 0 0 0
0.4
−2 −0.5 −0.5 −0.5
−40 0.2
−4 −2
−1 −1 −1 0
−6 −1 0 1 2 −60
0 5 10 0 pi/2 pi 0 pi/2 pi −1 0 1 −1 0 1 0 pi/2 pi

(i) (ii) (iii) (iv) LP HP (iii)

Figure 59: An example of a minimum-phase transfer function in Problem 33. Figure 61: An example of power-complementary LP and HP filters in Problem 33.

H4) If the amplitude response (z ← ejω ) is |H(ejω )| = 1 for all frequencies, then the filter H5) Linear-phase. This impulse response is a shifted (delayed) version of h1 [n]. The
is allpass (Mitra 4.6). The phase response differs from filter to filter. Allpass-filters frequency response is not any more real-valued, but still the phase response is linear
contain both zeros and poles mirror-symmetrically, and there is a certain symmetry and the group delay constant.
in the coefficients of numerator and denominator polynomials, too. Note that gain
cannot be seen from the pole-zero plot. H5 (ejω ) = e−jω · H1 (ejω )
In Figure 60 an allpass transfer function |H5 (ejω )| = |H1 (ejω )| = |2 − 2 cos(ω)|
∠H5 (ejω ) = −ω | linear
−0.288 + 0.4785z −1 − 0.007771z −2 − 0.09443z −3 + z −4
H(z) = −3.4722 · d
1 − 0.09443z −1 − 0.007771z −2 + 0.4785z −3 − 0.288z −4 − ∠H5 (ejω ) = 1 | constant

2 10
There are four types of linear-phase transfer functions (Mitra 4.4.3). Impulse re-
1
1
2
sponse of Type 1 is symmetric and odd-length. Type 2 is symmetric and even-length.
0
0
cont. 0.5 0
−2 Type 3 is antisymmetric and odd-length. Type 4 is antisymmetric and even-length.
0
−1
−0.5 −10
−4 The zeros have mirror-image symmetry respect to the unit circle.
−6
−2
−1 −8 In Figure 62 there is a Type 1 (length: 9, order: 8) impulse response, which is a
−3 −20
0 5 10 −1 0 1 2 0 pi/2 pi 0 pi/2 pi shifted version of the filter in Figure 57.
(i) (ii) (iii) (iv)
h[n] = {1, 3.2893, 3.8875, 0.0884, −3.0407, 0.0884, 3.8875, 3.2893, 1}
Figure 60: An example of an allpass transfer function in Problem 33. X
H(z) = h[n]z −n
n
A complemantary transfer function (Mitra 4.8) can be obtained using allpass filters.
An example of a lowpass filter
4
 1 0

HLP (z) = 0.5 A0 (z) + A1 (z) 2 0.5


0
−20
 −1  8
−a + z 0 0
= 0.5 1 + −40
−5
1 − az −1 −2
−0.5

 1 − a + z −1 − az −1  −4
−1
−60 −10
0 2 4 6 8 −1 0 1 0 pi/2 pi 0 pi/2 pi
= 0.5
1 − az −1 (i) (ii) (iii) (iv)
where A0 (z) and A1 (z) are allpass transfer functions and its power-complementary Figure 62: An example of a linear-phase transfer function in Problem 33.
highpass filter

HHP (z) = 0.5 A0 (z) − A1 (z)
 −1 
−a + z
= 0.5 1 −
1 − az −1
1 + a 1 − z −1
= ·
2 1 − az −1

In Figure 61(iii) is shown that |HLP (z)|2 + |HHP (z)|2 = 1, as expected by the defi-
nition of power-complementary transfer functions.

T-61.246 DSP 2005 79/140 SOLUTIONS T-61.246 DSP 2005 80/140 SOLUTIONS

P
34. Problem: Show that the periodic
P impulse train p(t) = ∞n=−∞ δ(t−nT ) can be expressed 35. Problem: Impulse
P∞ train in Problem 34 can be also expressed as a Fourier transform
as a Fourier series p(t) = T1 ∞
k=−∞ e
jΩT kt
, where ΩT = 2π/T is the sampling angular P (jΩ) = 2π
Ts k=−∞ δ(Ω − k Ωs ). Sampling can be modelled as multiplication in time
frequency. domain x[n] = xp (t) = x(t)p(t). What is Xp (jΩ) for an arbitrary input spectrum X(jΩ)?

Solution: Since p(t) Solution: The Fourier series of a continuous-time signal can be expressed

X
p(t) = δ(t − nT ) ∞
X
n=−∞ x(t) = ak ejkΩ0 t
k=−∞
is a periodic function of time t with a period T (time between samples), it can be repre-
sented as Fourier series (F-series for periodic, F-transform for non-periodic signals): where ak are Fourier coefficients and Ω0 is fundamental angular frequency. Fourier trans-

form of a periodic signal can be written in form of
X
j(2πnt/T )
p(t) = cn e ∞
X
n=−∞ X(jΩ) = 2πak δ(Ω − kΩ0 )
k=−∞
where Fourier coefficients (note, p(t) over one period T )
Z So, the impulse train p(t) of Problem 34 with all coefficients ak = 1/Ts and fundamental
1
cn = p(t) e−j(2πnt/T ) dt angular frequency Ωs can be written as
T T

TheRunit impulse function (continous-time) has properties 2π X
∞ P (jΩ) = δ(Ω − kΩs )
(1) −∞ δ(t) dt = 1, and Ts k=−∞
R∞
(2) −∞ δ(t)a(t) dt = a(t)|t=0 .
Therefore Fourier series coefficients are: Sampling in time and frequency domain can be modeled
Z 1 1
1 T /2 1 1 x[n] = x(t) · p(t) ↔

X(jΩ) ~ P (jΩ) =

P (jΩ) ~ X(jΩ) = X(ejω )
cn = δ(t) e−j(2πnt/T ) dt = e−j(2πnt/T ) |t=0 = 2π 2π
T −T /2 T T
R
Hence Using δ(t)x(t)dt = x(t)|t=0 ,
∞ ∞
X 1 X j(2πnt/T )
p(t) = δ(t − nT ) = e 2 1  1
Z ∞
n=−∞
T n=−∞ P (jΩ) ~ X(jΩ) = P (jθ)X(j(Ω − θ))dθ
2π 2π −∞

Z ∞
2π X
1
= δ(θ − kΩs )X(j(Ω − θ))dθ

Ts k=−∞ −∞
∞ Z ∞
1 X
= δ(θ − kΩs )X(j(Ω − θ))dθ
Ts k=−∞ −∞

1 X
= X(j(Ω − kΩs ))
Ts k=−∞

In other words, the spectrum X(ejω ) of the discrete-time signal x[n] can be obtained
by summing the shifted spectra X(jΩ) of the corresponding analog signal x(t). Spectra
X(jΩ) are scaled by (1/Ts ) and copied at every sampling (angular) frequency.
T-61.246 DSP 2005 81/140 SOLUTIONS T-61.246 DSP 2005 82/140 SOLUTIONS

36. Problem: Suppose that a continuous-time signal x(t) and its spectrum |X(jΩ)| in Fig- 37. Problem: Consider a continuous-time signal x̃(t) = cos(2πf1 t) + cos(2πf2 t) + cos(2πf3 t),
ure 63 are known. The highest frequency component in the signal is fh . The signal is where f1 =100 Hz, f2 =300 Hz and f3 =750 Hz. The signal is sampled using frequency fs .
sampled with frequency fs , i.e. the interval between samples is Ts = 1/fs : x[n] = x(nTs ). Sketch the magnitude of the Fourier spectrum of x[n], when fs equals to (i) 1600 Hz (ii)
Sketch the spectrum |X(ejω )| of the discrete-time signal, when (a) fh = 0.25 fs , (b) 800 Hz (iii) 400 Hz.
fh = 0.5 fs , (c) fh = 0.75 fs . |X(jw)| Use an ideal reconstruction lowpass filter whose cutoff frequency is fs /2 for each case.
1 What frequency components can be found in reconstructed analog signal xr (t)?

fh
Solution: There is a continuous-time signal
Figure 63: Spectrum X(jΩ) in Problem 36 also at page 14.
x(t) = cos(2πf1 t) + cos(2πf2 t) + cos(2πf3 t)
Let f1 = 100 Hz, f2 = 300 Hz and f3 = 750 Hz.
Solution: The spectrum X(jΩ) of a real analog signal is symmetric around y-axis. It is possible directly to express the Fourier transform of a periodic signal using transform
When sampling, the spectrum X(ejω ) is 2π-periodic (sampling frequency) pairs (or see Page 80). In this case using Hertz

∞ X(jf ) = π · δ[f + 750] + δ[f + 300] + δ[f + 100] + δ[f − 100] + δ[f − 300] + δ[f − 750]
1 X
x[n] = xp (nTs ) = x(t)p(t) ↔ X(ejω ) = X(j(Ω − kΩs ))
Ts k=−∞
The signal is sampled with sampling frequency fs , (T = 1/fs ).
 
a) Figure 64. The highest component of x(t) is only 0.25 · fs ⇒ No aliasing. n f1 f2 f3
x[n] = x(nT ) = x( ) = cos(2π n) + cos(2π n) + cos(2π n)
fs fs fs fs
|Xp (jω )|
1
In the frequency domain the discrete-time spectrum Gp (jΩ) can be seen as a sum of shifted
fh f s /2 fs
and scaled replicas of the analog spectrum Ga (jΩ) as shown in Problems 35 and 36 (Eq.
5.9 in Mitra):
Figure 64: fh = 0.25 fs, no aliasing in Problem 36(a). 1 X

Gp (jΩ) = Ga (j(Ω − kΩT ))
T k=−∞
b) Figure 65. Case: Nyquist frequency, half of the sampling frequency. Alternatively, sampling can be considered as flipping the analog spectrum around each
half of the sampling frequency down to the band 0 . . . fs /2.
|Xp (jω )|
1 Reconstruction means converting a digital sequence back to analog signal. An ideal
lowpass filter with the passband up to half of the sampling frequency is used. When
fh reconstructing signals we can only observe frequencies up to Nyquist frequency. 1 If there
f s /2 fs 2f s are frequencies over the Nyquist frequency in the original signal, those frequencies are
Figure 65: fh = 0.5 fs , critical sampling in Problem 36(b). aliased into low frequencies.
In this problem X(jΩ) is sampled with three different sampling frequencies fs of 1600 Hz,
800 Hz and 400 Hz, The Nyquist frequency is the half of the sampling frequency fs /2,
c) Figure 66. Aliasing takes place. X(ejω ) is the sum of all folded analog spectra. The 800 Hz, 400 Hz, and 200 Hz, respectively. Let fm (in this case 750 Hz) be the biggest
spectrum X(ejω ) is depicted in Figure 66 with a thick continuous line.
frequency found in the input signal. The Nyqvist rate is 2fm = 1500 Hz. If the sampling
  frequency is less than Nyqvist rate, then there will be aliasing.
1
X(ejω ) = ... + X(j(Ω − Ωs )) + X(jΩ) + X(j(Ω + Ωs )) + ...
Ts In the following figures for i, ii and iii, the scale and magnitude values for aliased frequen-
cies are not exactly correct. Phase shifts in input signal cause that a pure addition of
magnitudes will not hold. (The sum of two cosines with same frequency and phase shift
|Xp (jω )|
1
of π is zero. However, in practice, this is rarely significant.)

i) fs = 1600 Hz, highest frequency component fm = 750 Hz. The inequality 1600 >
fh 2 · 750 holds, hence, there is no aliasing. All three frequencies can be recovered. See
f s /2 f s 2f s 3f s
Figure 67.
Figure 66: fh = 0.75 fs , aliasing in Problem 36(c). 1
There is variation in using “Nyqvist frequency” in the literature. It is either (1) half of the sampling
frequency (Mitra p. 302) or (2) twice the highest frequency in the signal (Mitra p. 304). The reader should not
confuse with this.

T-61.246 DSP 2005 83/140 SOLUTIONS T-61.246 DSP 2005 84/140 SOLUTIONS

fs = 1600 Hz 1
x (t)

2 T=(1/750)=1.33ms
0
x(t)

0
−2

|X a (jw)| 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 −1
x(t).p(t)

2
0
1
x[n]

−2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
0
2
x[n]

200 600 w (f, Hz) 0 −1


fs /2 −2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
1
reconst.

x (t)

|X p (jw)| 2
0
3r

0
−2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
−1
2
0 2 4 6 8 10 12 14 16 18 20 t (ms)
x (t)

0
r

200 600 1000 w (f, Hz) −2


0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
Figure 69: Demonstration of aliasing of a single cosine in Problem 37(ii).

Figure 67: Sampling in Problem 37(i) with sampling frequency 1600 Hz: original analog spec- iii) fs = 400 Hz, highest frequency component fm = 750 Hz. The inequality 400 > 2 ·750
trum X(jΩ) (left top), and spectrum X(ejω ) of the discrete-time signal (left bottom). Time does not hold, hence, there is aliasing. All frequencies over 200 Hz are missed (300
domain view (right), top down x(t), sampling x(t) · p(t) sampled sequence x[n] to be processed and 750 Hz). There are new alias components at frequencies 50 and 100 Hz. See
with DSP, reconstruction, and reconstructed continuous-time signal xr (t). Again, in this case Figure 70.
no aliasing, i.e. x(t) ≡ xr (t). cos(2π 750 n) = cos(2π 750 n − 4πn) = cos(2π −50 50
n) = cos(2π 400 n)
400 400 400
cos(2π 300
400
n) = cos(2π 300
400
n − 2πn) = cos(2π −100
400
100
n) = cos(2π 400 n)
ii) fs = 800 Hz, highest frequency component fm = 750 Hz. The inequality 800 > 2 ·750 fs = 400 Hz

does not hold, hence, there is aliasing. All frequencies over 400 Hz are missed (750 Hz 2
x(t)

in this case); they cannot be observed. There is a new alias component at frequency |X a (jw)|
−2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
x(t).p(t)

50 Hz. See Figure 68. 3 2 1 1 2 3 0


−2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02

fs = 800 Hz 2
x[n]

200 600 w (f, Hz) 0


2 fs /2 −2
x(t)

0 |X p (jw)| 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
reconst.

−2 2
2 2 2 2
|X a (jw)| 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0
x(t).p(t)

2 3 3 3 3 −2

3 2 1 1 2 3 0 1 1 1 1 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02

−2 2
x (t)

0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0
r

2 200 600 1000 w (f, Hz) −2


x[n]

200 600 w (f, Hz) 0 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
fs /2 −2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02
reconst.

|X p (jw)| 2
0
3 3 2 1 3 3 1 2
2 1 1 2 −2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 Figure 70: Sampling in Problem 37(iii) with sampling frequency 400 Hz. Aliasing occurs again,
2

x(t) 6= xr (t).
x (t)

0
r

200 600 1000 w (f, Hz) −2


0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02

Figure 68: Sampling in Problem 37(ii) with sampling frequency 800 Hz. Aliasing occurs, After ideal reconstruction (x[n] → xr (t)) there are the following components left:
x(t) 6= xr (t), compare the top and bottom axis in the figure right.
(i) original 100, 300, 750 Hz.
(ii) original 100, 300 Hz, and an alias 50 Hz.
Before going further, there is a short demonstration on the aliasing signal component
x3 (t) (fi = 750 Hz) of the signal x(t) in Figure 69. The figures are depicted in (iii) original 100 Hz, and aliases 50, 100 Hz.
time-domain: (a) original x(t) with period T = 1/f = (1/750) = 1.333 ms, (b)
There is a sampling (aliasing) demo in http://www.cis.hut.fi/Opinnot/T-61.246/
samples x[n] using interval Ts = 1/fs = (1/800) = 1.250 ms, (c) reconstructed
Demo/esim6.shtml, which can be also loaded to Matlab.
signal x3r (t), whose period Tr = (1/50) = 20 ms. The same aliasing effect can be
shown using the cosine function, which is 2π-periodic (cos(ωn) ≡ cos(ωn + 2π)) and
even (cos(−ωn) ≡ cos(ωn)). The highest component x3 (t) of 750 Hz aliases in the
sampling and reconstructing process to 50 Hz:

x3 (t) = cos(2π 750t) | original: 750 Hz


x3 [n] = x3 (n/fs ) = cos(2π(750/800)n) = cos(2π(750/800)n − 2πn) | 2π-periodicity
= cos(2π(−50/800)n) = cos(2π(50/800)n) | even function
x3r (t) = cos(2π 50t) | reconstructed: 50 Hz
T-61.246 DSP 2005 85/140 SOLUTIONS T-61.246 DSP 2005 86/140 SOLUTIONS

38. Problem: Sketch specifications and compute the order for an anti-aliasing Butterworth 39. Problem: Derive the transfer function of the feedback system shown in Figure 73.
filter with fs = 8 kHz, interesting band 0 . . . 2 kHz, and minimum stopband attenuation
50 dB. x[n] w[n] y[n]
E(z) F(z)

Solution: An anti-aliasing filter is an analog lowpass filter used in order to remove


G(z)
components, which cause aliasing when sampling (Mitra 5.6). Consider an analog signal
x(t) and its spectrum X(jΩ) depicted in Figure 71.
Figure 73: System in Problem 39.
|X|

Solution: Systems in parallel, see Figure 74: Hp (z) = H1 (z) + H2 (z) in frequency
domain and hp [n] = h1 [n] + h2 [n] in time domain. Systems in cascade, see Figure 75:

f
2 4 6 8 kHz H1 (z)
Figure 71: Spectrum X(jΩ) in Problem 38.

H2 (z)
In the following, notations of Mitra’s figure 5.28 are used, Ωp for passband edge frequency,
Ω0 = ΩT − Ωp for stopband edge frequency, and ΩT for sampling frequency. Now that the
interesting band stops at Ωp = 2 kHz and the sampling frequency is ΩT = 8 kHz, we can Figure 74: Systems in parallel, example in Problem 39.
set the edge frequency for the stopband to be at Ω0 = (8 − 2) = 6 kHz (see Figure 72).
After sampling there will be aliasing components in 2 . . . 4 kHz, but we are not interested Hc (z) = H1 (z)H2 (z) in frequency domain and hc [n] = h1 [n] ~ h2 [n] in time domain.
in them, i.e. we use digital filtering for that band. The flow diagram of the system being investigated with temporary variable w[n] is in

|X|
H1 (z) H2 (z)

Figure 75: Systems in cascade, example in Problem 39.

f Figure 76. We get the following equations:


2 4 6 8 kHz
Figure 72: Problem 38: Spectrum X(jΩ), specifications for a LP filter (dashed line), frequency 
Y (z) = F (z)W (z)
components that would alias in 0 . . . 2 kHz without anti-aliasing filtering (gray). W (z) = E(z)X(z) + G(z)Y (z)

When the specifications are not so tight as they normally (cut-off at 4 kHz) are, also the Y (z) = F (z) (E(z)X(z) + G(z)Y (z))
order of the anti-aliasing filter is lower. The design of the anti-aliasing filter can be made Y (z) (1 − F (z)G(z)) = (F (z)E(z)) X(z)
even easier by increasing sampling frequency with analog circuits (order of anti-aliasing
filter decreases), and afterwards decrease sampling frequency using multirate techniques Y (z) F (z)E(z)
H(z) = =
(Mitra, Chapter 10). X(z) 1 − F (z)G(z)
Calculations using the table 5.1 in Mitra or Table 7: Ω0 /Ωp = 3 → N = d50/9.54e = 6.
Note that if the passband ended at 2 kHz and the stopband started at 4 kHz, the required E(z)X(z)
X(z) W(z) Y(z) Y(z)
order of the filter would be 10. E(z) F(z)

Ω0 = 2Ωp 3Ωp 4Ωp Y(z)


Attenuation (dB) 6.02N 9.54N 12.04N G(z)Y(z) G(z)
ΩT = 3Ωp 4Ωp 5Ωp
Figure 76: System in Problem 39.
Table 7: Approximate minimum stopband attenuation of a Butterworth lowpass filter. Mitra
Table 5.1, page 336. See the text in Problem 38 for details.

T-61.246 DSP 2005 87/140 SOLUTIONS T-61.246 DSP 2005 88/140 SOLUTIONS

40. Problem: Develop a polyphase realization of a length-9 FIR transfer function given by where
8
X
−n H0 (z) = h[0] + h[4]z −1 + h[8]z −2
H(z) = h[n]z
n=0
H1 (z) = h[1] + h[5]z −1
with (a) 2 branches and (b) 4 branches.
H2 (z) = h[2] + h[6]z −1
Solution: Polyphase realizations (Section 6.3.3 in Mitra) can be used in multirate tech- H3 (z) = h[3] + h[7]z −1
niques.
a) Two branches
H0 (z 4 )
8
X
H(z) = h[n]z −n
n=0 z −1

−1 −2 −3 −4
= h[0] + h[1]z + h[2]z + h[3]z + h[4]z +
H1 (z 4 )
h[5]z −5 + h[6]z −6 + h[7]z −7 + h[8]z −8
 z −1
= h[0] + h[2]z −2 + h[4]z −4 + h[6]z −6 + h[8]z −8 +

z −1 h[1] + h[3]z −2 + h[5]z −4 + h[7]z −6
H2 (z 4 )

= H0 (z 2 ) + z −1 H1 (z 2 )
z −1
where
H0 (z) = h[0] + h[2]z −1 + h[4]z −2 + h[6]z −3 + h[8]z −4 H3 (z 4 )

−1 −2 −3
H1 (z) = h[1] + h[3]z + h[5]z + h[7]z
Figure 78: Polyphase realization with four branches in Problem 40(b).

H0 (z 2 )

z −1

H1 (z 2 )

Figure 77: Polyphase realization with two branches in Problem 40(a).

b) Four branches
8
X
H(z) = h[n]z −n
n=0

= h[0] + h[1]z −1 + h[2]z −2 + h[3]z −3 + h[4]z −4 +


h[5]z −5 + h[6]z −6 + h[7]z −7 + h[8]z −8
 
= h[0] + h[4]z −4 + h[8]z −8 + z −1 h[1] + h[5]z −4 +
 
z −2 h[2] + h[6]z −4 + z −3 h[3] + h[7]z −4

= H0 (z 4 ) + z −1 H1 (z 4 ) + z −2 H2 (z 4 ) + z −3 H3 (z 4 )
T-61.246 DSP 2005 89/140 SOLUTIONS T-61.246 DSP 2005 90/140 SOLUTIONS

41. Problem: Analyze the digital filter structure shown in Figure 79 and determine its b) Since the structure employs 4 unit delays to implement a second-order transfer func-
transfer function H(z) = Y (z)/X(z). tion, it is not canonic.
Canonic structure: the number of registers, i.e. delay components, is the same
a) Is the system LTI?
as the filter order. Direct form I is not canonic, but it is intuitive and its difference
b) Is it a canonic structure? equation is easy to obtain. Direct form II is canonic. It is more efficient to use
c) Compute H(z)H(z −1 ) (the squared amplitude response). What is the type of this canonic structures. (Consider, for example, Problem 49. If canonic structure is
filter (lowpass/highpass/bandpass/bandstop/allpass)? used, there are only 8 storage locations instead of 10.)
c)
Solution: Let us use three temporary signals w1 [n], w2 [n], and w3 [n], in the following   
B − Az −1 + z −2 B − Az 1 + z 2 z −2
locations in Figure 79. H(z)H(z −1 ) = K 2 | ·
1 − Az −1 + Bz −2 1 − Az 1 + Bz 2 z −2
 −1 −2
  −2 −1

B − Az + z Bz − Az + 1
= K2
W1 W2 y[n] 1 − Az −1 + Bz −2 z −2 − Az −1 + B
x[n]
z−1 z−1 = K 2
K
−1 Therefore |H(ejω )| = K for all values of ω and hence |H(ejω )| = 1 if K = 1. H(z) is
an allpass transfer if K = 1.

A B
−1
W3
z−1 z−1

Figure 79: The filter with temporary signals w1 , w2 , and w3 in Problem 41.

From the figure we get the following expressions in transform-domain (W ≡ W (z)):

W1 = KX + z −1 W3

W2 = (z −1 − A)W1

W3 = AW1 − Bz −1 W1 = (A − Bz −1 )W1

Y = z −1 W2 + BW1

Substituting the equation from third line to first line we get

W1 = KX + z −1 (A − Bz −1 )W1
(1 − Az −1 + Bz −2 )W1 = KX

Next, substituting second line in fourth line we get

Y = [z −1 (z −1 − A) + B]W1

Finally, we get rid of the last temporary variable W1 , and get

Y (z) B − Az −1 + z −2
H(z) = =K·
X(z) 1 − Az −1 + Bz −2

a) It is LTI. There are only multiplications by constants, delays, and sums of sequences.

T-61.246 DSP 2005 91/140 SOLUTIONS T-61.246 DSP 2005 92/140 SOLUTIONS

42. Problem: The filter in Figure 80 is in canonic direct form II. x[n] w[n] y[n] x[n] y[n]
w[n] w[n]
a) Duplicate first the registers in the middle line and flip the order of “IIR” and “FIR” z −1 z −1 z −1 z −1
parts (both subsystems are LTI!). The result should be a structure in Direct Form 0.9 0.8 0.8 0.9
I, from which the transfer function H(z) can be easily constructed.
b) The transfer function can be obtained directly from the diagram using temporary z−1 z−1
−0.2 −0.2
variable w[n] and z-transform. What is H(z) in this (much harder) way? "IIR" "FIR" "FIR" "IIR"

(a) (b)
Solution: Direct form structure means that the coefficients of the block diagram are the
same (or negative values) as in the difference equation and transfer function. There are Figure 81: From direct form II to direct form I in Problem 42(a).
also other structures, e.g. lattice. The transfer function for any direct form (I, II, and
transposes IT , IIT , respectively, see Page 92) is the same. Some differences (may) occur
when working with finite word length. There are also differences in computational load From the latter one, W (z) = X(z)/(1 − 0.9z −1 + 0.2−2 ), and substituting into the
and memory storage. first one, we get

1 + 0.8z −1
a) The block diagram in Figure 80 is in canonic direct form II. Y (z) = X(z)
1 − 0.9z −1 + 0.2−2
x[n] w[n] y[n] 1 + 0.8z −1
H(z) = Y (z)/X(z) =
1 − 0.9z −1 + 0.2−2
z −1 Using inverse z-transform we get difference equation which can be easily drawn as
0.9 0.8 direct form I block diagram:

1 + 0.8z −1
Y (z)/X(z) =
z−1 1 − 0.9z −1 + 0.2−2
−0.2 Y (z)(1 − 0.9z −1 + 0.2−2 ) = X(z)(1 + 0.8z −1 )
y[n] − 0.9y[n − 1] + 0.2y[n − 2] = x[n] + 0.8x[n − 1]
Figure 80: The block diagram of direct form II in Problem 42.
Direct Forms
If we want to convert it into direct form I without any calculations (done below
in (b)), we can duplicate the registers. The same signal w[n] goes into the both Mitra p. 369-371. Direct form: coefficients of difference equation or transfer function can
branches. See Figure 81(a). be found in block diagram. (This is not the case, for example, in lattice form.) Common
Then we can denote the part in left as an “IIR subsystem” and the structure in right in all forms is that they have the same transfer function, but the “implementation” is
as an “FIR subsystem”. Because both of them are LTI, we can change the order of different.
them, as in any LTI system, for example, using impulse responses
Let the transfer function be
h[n] = hIIR [n] ~ hF IR [n] ≡ hF IR [n] ~ hIIR [n] Y (z) 1 + 0.5z −1
H(z) = =
X(z) 1 − 0.2z −1 + 0.4z −2
Now we have direct form I in Figure 81(b), and the difference equation and the
transfer function can be obtained directly without any temporal variables! However, In the top numerator polynomial 1 + 0.5z −1 refers to “FIR part” P (z) and in the bottom
there are now three registers instead of two. denominator polynomial 1 − 0.2z −1 + 0.4z −2 “IIR part” D(z):
b) The transfer function and difference equation can be derived directly from the filter
1
in Figure 80: H(z) = P (z)
D(z)
y[n] = w[n] + 0.8w[n − 1]
How to get difference equation and block diagram from tranfer function,
w[n] = x[n] + 0.9w[n − 1] − 0.2w[n − 2]

Using z-transform

Y (z) = W (z) + 0.8z −1 W (z) = W (z)(1 + 0.8z −1 )


W (z) = X(z) + 0.9z −1 W (z) − 0.2z −2 W (z)
T-61.246 DSP 2005 93/140 SOLUTIONS T-61.246 DSP 2005 94/140 SOLUTIONS

z-transform ax[n − n0 ] ↔ a z −n0 X(ejω ): order of subfilters can be changed. Connect the delay registers, because there are the
same signals (see Book). So you get canonic form, where the number of delays is the
Y (z) 1 + 0.5z −1
H(z) = = same as order of the filter (Figure 84).
X(z) 1 − 0.2z −1 + 0.4z −2

X(z)[1 + 0.5z −1 ] x[n] w[n]


1 y[n] x[n] w[n]
1 y[n]
Y (z) = w[n] w[n]
1 − 0.2z −1 + 0.4z −2 −1 −1
-1
z
z z
0.2 0.2 0.5
Y (z)[1 − 0.2z −1 + 0.4z −2 ] = X(z)[1 + 0.5z −1 ] 0.5

Y (z) − 0.2z −1 Y (z) + 0.4z −2 Y (z) = X(z) + 0.5z −1 X(z) -1


−1
z z
y[n] − 0.2y[n − 1] + 0.4y[n − 2] = x[n] + 0.5x[n − 1] −0.4 -0.4
y[n] = 0.2y[n − 1] − 0.4y[n − 2] + x[n] + 0.5x[n − 1]
1
"IIR" "FIR" "IIR" "FIR"
Direct form I can be drawn directly H(z) = P (z) · D(z)
, first “FIR” and then “IIR” IIR-FIR before connecting Canonic form
(Figure 82).
Figure 84: Direct form II.
x[n] 1 y[n]
−1 −1
z z Corresponding transponing IIT , see Figure 85.
0.5 0.2

y[n] "IIR" 1 x[n] x[n] 1 "IIR" y[n]


−1
z
−0.4
-1 −1
z z
"FIR" "IIR" 0.2 0.5 0.5 0.2

Figure 82: Direct form I. You may connect FIR and IIR parts in the middle sum line. -1 −1
-0.4 z z −0.4
"FIR"
When transposing (Figure 83) transfer function stays, but structure changes. “Rules” "FIR"
for transposing: Phases 1-3 Phase 4: flip around
1 Change directions
2 Nodes to sums Figure 85: Transposed direct form II.
3 Sums to nodes
4 Flip the whole structure
Example on direct form, cascade and parallel system. Consider a second order transfer
y[n] x[n] x[n] y[n] function
1 w[n] 1 1 1
H(z) = =
w[n] w[n] (1 + 13 z −1 )(1 − 41 z −1 ) 1 −1
1 + 12 1 −2
z − 12 z
−1 −1 -1 -1
z z z z with difference equation
0.2 0.2 0.5
0.5
1 1
y[n] = − y[n − 1] + y[n − 2] + x[n]
−1 -1 12 12
z z
−0.4 -0.4
Cascade form can be written as
  
"FIR" "IIR" "IIR" "FIR" 1 1
Phases 1-3 Phase 4: flip around. You may connect H(z) =
1 + 13 z −1 1 − 14 z −1
parts in the middle line.
and parallel form using partial fraction (draw!)
Figure 83: Transposed direct form I.
4 3
7 7
H(z) = +
Direct form II contains minimum number of delay registers. Draw in order “IIR” and 1 + 13 z −1 1 − 14 z −1
1
then “FIR”. Think the transfer function in order H(z) = D(z) · P (z). Because LTI, the

T-61.246 DSP 2005 95/140 SOLUTIONS T-61.246 DSP 2005 96/140 SOLUTIONS

43. Problem: Develop a canonic direct form realization of the transfer function 44. Problem: Sketch the following specifications of a digital filter on paper. Which of the
amplitude responses of the realizations in Figure 88 do fulfill the specifications?
2 + 4z −1 − 7z −2 + 3z −5
H(z) = Specifications: Digital lowpass filter, sampling frequency fT 8000 Hz, passband edge fre-
1 + 2z −1 + 5z −3
quency fp 1000 Hz, transition band 500 Hz (transition band is the band between passband
and then determine its transpose configuration. and stopband edge frequencies!), maximum passband attenuation 3 dB, minimum stop-
band attenuation 40 dB.
Solution: There is a canonic direct form II realization of H(z) in Figure 86. Its
transposed realization can be achieved Solution: The frequency specifications are in Hertz, radians, and in normalized Matlab
frequency in Table 8 and they are drawn in Figure 88 with dashed line.
• by changing the direction of the flow to opposite,
• by replacing each sum node with a branch node, and sampling frequency fT 8000 Hz ωT 2π (rad) 2
passband edge fp 1000 Hz ωp π/4 (rad) Wp 2 · 1000/8000 = 0.25
• by replacing each branch node with a sum node stopband edge fs 1500 Hz ωs 3π/8 (rad) Ws 2 · 1500/8000 = 0.375
passband ripple Rp 3 dB Rp 3
2
stopband attenuation Rs 40 dB Rs 40

4
Table 8: Specifications for the filter in Problem 44.

-7 Now that specifications are written and sketched, the filter order and the filter coefficients
are computed using a specific software (e.g. Matlab, ellipord and ellip, buttord and
3
butter, etc.). Then the amplitude response |H(ejω )| of the calculated filter is plot-
z −1 z −1 z −1 z −1 z −1 ted in the same picture as the sketch of the specifications (e.g. Matlab, [...] =
freqz(B,A,...);). If the amplitude response curve fits in the specifications, we have
-2
succeeded. In other case, the specifications and the code for the filter are re-checked.
More information on the filter synthesis using Matlab in Matlab exercises and in this
-5
material from page 131.
The elliptic IIR filter in Figure 88(a) (via bilinear transform) is of order 4 and it fulfills
Figure 86: Canonic direct form II in Problem 43. the specifications exactly.
Chebychev II filter (Figure 88(b)), which is 10th order IIR, is monotonic in passband
The end result is in Figure 87. and has stopband attenuation of 50 dB instead of 40. The amplitude response fits in the
allowed area, and it is already too strict. Probably the order N = 8 would be sufficient.
2
The third filter (Figure 88(c)) is 50th order FIR, whose transition is narrow enough but
4
at the wrong cut-off frequency. So, this is the only filter, which does not fulfill the
specifications. One should check the cut-off frequency so that the amplitude response fits.
-7 (a) Elliptic, N=4 (b) Chebychev II, N=10 (c) FIR/Hamming, N=50
Ampl.resp. Ampl.resp. Ampl.resp.
0 Specifications 0 Specifications 0 Specifications

3 −10 −10 −10


z −1
z −1
z −1
z −1
z −1
−20 −20 −20
−30 −30 −30
dB

dB

dB

-2
−40 −40 −40
−50 −50 −50
-5
−60 −60 −60
−70 −70 −70
0 2000 4000 0 2000 4000 0 π/2 π
Hz Hz ω
Figure 87: Transposed canonic direct form II in Problem 43.
Figure 88: Three realizations in Problem 44: amplitude responses (solid line) with specifications
(dashed line) of (a) 4th order elliptic (OK!), (b) 10th order Chebychev II (OK, too tight
realization?), (c) 50th order FIR using Hamming window (bad cut-off frequency).
T-61.246 DSP 2005 97/140 SOLUTIONS T-61.246 DSP 2005 98/140 SOLUTIONS

45. Problem: Connect first each amplitude response to the corresponding pole-zero plot 46. Problem: Magnitude specifications are normally expressed in normalized form. The
in Figure 89. Then recognize the following digital IIR filter algoritms: Butterworth, amplitude is scaled to unity (0..1 or −∞..0 dB), and the frequency axis is scaled up to
Chebyshev I, Chebyshev II, Elliptic. The conversion from analog to digital form is done half of the sampling frequency, 0..π, or 0..1. The first term of the denominator polynomial
using bilinear transform. should also be 1.
Consider the following digital lowpass filter of type Chebyshev II:
Solution: Analog filter design is represented in Section 5.4 in Mitra. The approximations
are given with magnitude-squared responses of Nth order in Table 9. 0.71 − 0.36z −1 − 0.36z −2 + 0.71z −3
H(z) = K ·
1 − 2.11z −1 + 1.58z −2 − 0.40z −3
Approximation Section Response
Normalize the maximum of the amplitude response to the unity (0 dB).
1
Butterworth 5.4.2 |Ha (jΩ)|2 =
1+(Ω/Ωc )2N Solution: Chebyshev II approximation is monotonic in the passband, see Figure 90.

2 1 H(z) = K ⋅ B(z) / A(z)


Chebyshev I 5.4.3 |Ha (jΩ)| = 2 (Ω/Ω )
1+2 TN p 10

1
Chebyshev II 5.4.3 |Ha (jΩ)|2 = T (Ω /Ωp ) 2
8
1+2 [ TN (Ωs /Ω) ]
N s 6
1
Elliptic 5.4.4 |Ha (jΩ)|2 = 2 (Ω/Ω )
1+2 RN p 4

2
Table 9: Analog filter approximations in Problem 45.
0
The response of Butterworth is monotonic. Chebyshev I is equiripple in the passband 0 0.2 0.4 0.6 0.8 1

and monotonic in the stopband whereas Chebyshev II is monotonic in the passband and
equiripple in the stopband. Elliptic approximation is equiripple both in the passband Figure 90: Problem 46, H(z) = K · B(z)/A(z) without magnitude scaling.
and stopband. The filter order can often be obtained by computing the number of local
maximum and minimum.
Therefore the maximum value of the amplitude response of the lowpass Chebyshev II
The digital filters are obtained through bilinear transform (Section 7.2). Hence, approx- filter is at ω = 0. The gain K can be computed also in z-plane using z = ejω |ω=0 = 1.
imations, amplitude responses and pole-zero plots are related to each other according to
the Figure 89.
0.71 − 0.36z −1 − 0.36z −2 + 0.71z −3

Chebychev I, N = 7 Elliptic, N = 4 Chebychev II, N = 7 Elliptic, N = 4 |H(z)| = K
0 0 1 1
1 − 2.11z −1 + 1.58z −2 − 0.40z −3
−20 −20 0.5 0.5 0.71 − 0.36z −1 − 0.36z −2 + 0.71z −3

−40 −40
0 0 |H(z)|z=1 = K =1
−0.5 −0.5 1 − 2.11z −1 + 1.58z −2 − 0.40z −3
−60 −60 −1 −1
0 5000 10000 0 5000 10000
Butterworth, N = 19 Hz II, N = 7
Chebychev
−1 0 1 −1 0 1 0.70
0 0
Chebychev I, N = 7 Butterworth, N = 19 = K =1
1 1 0.07
−20 −20 0.5 0.5

−40 −40
0 0 ⇒ K = 0.1
−0.5 −0.5
−60 −60
0 5000 10000 0 5000 10000 −1 −1
Hz −1 0 1 −1 0 1 Remember also that when |H(z)|max = 1, then this maximum reference level is in (power)
desibels |H(z)|max = 20 log10 (1) = 0 dB.
Figure 89: Problem 45, see the titles of each subfigure for filter type and order.

T-61.246 DSP 2005 99/140 SOLUTIONS T-61.246 DSP 2005 100/140 SOLUTIONS

47. Problem: Consider the following prototype analog Butterworth-type lowpass filter The bilinear transformation is acquired when
1 1 − z −1
HprotoLP (s) = s=k·
s+1 1 + z −1
a) Form an analog first-order lowpass filter with cutoff frequency Ωc by substituting
H(s) = HprotoLP ( Ωsc ). Draw the pole-zero plot in s-plane. is inserted into the system function (Eq. 7.21)
b) Implement a discrete first-order lowpass filter HImp (z), whose cutoff frequency (-3
dB) is at fc = 100 Hz and sampling rate is fs = 1000 Hz, applying the impulse- H(z) = Ha (s)|s=k· 1−z−1
1+z −1
invariant method to H(s). Draw the pole-zero plot of the filter HImp (z).
c) Implement a discrete first-order lowpass filter HBil (z) with the same specifications Note that here k is a parameter used in the derivation of the bilinear transform. It is
applying the bilinear transform to H(s). Prewarp the edge frequency. Draw the originally k = (2/T ) but can be set k = 1 to simplify the procedure.
pole-zero plot of the filter HBil (z). The frequency is warped in the transform (see Figures 7.4 and 7.5 in Mitra, or lecture
slides). In the small frequencies the difference is not big, but is significant in high fre-
quencies. Therefore the discrete-time normalized angular cut-off frequency ωc has to be
Solution: The solution to the problem starts from the page 100. Two methods for
first prewarped into analog-time prewarped cut-off frequency Ωpc :
digital IIR design are shown in the lecture slides, impulse invariant method and bilinear
transform method. ω 
c
Ωpc = k · tan
Analog Butterworth lowpass filter 2
2
The definition of an analog Butterworth filter with cut-off frequency Ωc is |Ha (jΩ)| = where ωc = 2πfc /fT = 2πfc T = Ωc T , and 0 < ωc < π, and [fc ] = Hz, and fT = 1/T is
1/(1 + ( ΩΩc )2N ) (Mitra Eq 5.31). The first order (N = 1) filter is therefore the sampling frequency.
1 Solution to Problem 47
|Ha (jΩ)|2 =  2

1+ Ωc a) Substitution gives directly
1 1
Ha (s)Ha (−s) =  2 =  2 Ωc
1+ s
1− s H(s) = HprotoLP (s/Ωc ) =
jΩc Ωc s + Ωc
=H(s) H(−s)
z }| { z }| { The pole-zero plot of a lowpass filter in s-plane is in Figure 91.
1 1
=   ·  
1 + Ωsc 1 + −s
Analog LP filter Ha(s)=Ωc/(s+Ωc)

Ωc
Im s

where s = jΩ
Ωc
⇒ Ha (s) = Re s
s + Ωc
Ωc
The pole is (only the stable pole (s = −Ωc ) is chosen (Eqs. 5.32, 5.33))
s + Ωc = 0 ⇒ s = −Ωc

Here, Ω refers to frequency in analog domain (H(jΩ)) and ω to frequency in digital


domain (H(ejω )). Ωc is normally prewarped. Figure 91: Problem 47(a), LP in s-plane. The stable pole is at s = −Ωc in the left subspace,
the y-axis is the frequency.
As said earlier, there are two ways to convert analog filter to digital. The inpulse-invariant
method is straigtforward but it has severe limitations. The bilinear transform is a standard
b) Transfer function using the impulse-invariant method.
way.
Impulse-invariant method, see, e.g. lecture slides: Ωc
Ha (s) = 7→ ha (t) = Ωc e−Ωc t µ(t) 7→
s + Ωc
Ha (s) 7→ ha (t) 7→ h[n] = ha (nT ) 7→ H(z) ∞
X Ωc
h[n] = ha (nT ) = Ωc e−Ωc nT µ[n] 7→ H(z) = Ωc e−Ωc nT z −n =
In the impulse-invariant method the target is to get impulse response of digital filter h[n] n=0
1 − e−Ωc T z −1
to be the same as the sampled impulse response of analog filter ha (nT ). Because IIR
filters have normally an impulse response of infinite length, this method brings distortion.
T-61.246 DSP 2005 101/140 SOLUTIONS T-61.246 DSP 2005 102/140 SOLUTIONS

The constant K is introduced in order to scale the maximum of |H(ejω )| into unity. The last task is to normalize the transfer function. The constant term in denominator
Using Eq. 7.7 in Mitra (ωc = Ωc /fT = 2πfc /fT ) and values fT = 1 kHz (sampling polynomial should be scaled to 1, and the maximum value of the amplitude response
frequency) and fc = 100 Hz (cut-off frequency), to 1. While this is a Butterworth lowpass filter, the maximum is reached at
ω = 0, i.e., z = ejω |ω=0 = 1.
K K
H(z)Imp = =
1 − e−ωc z −1 1 − e−π/5 z −1
1 + z −1

|H(z)Bil |max = K · 1−tan(0.1π) −1 z=1
=1
We also know that the maximum is located at zero frequency, because the frequency 1− 1+tan(0.1π)
z
response of a Butterworth filter is monotonic. Thus we get
Finally,
K 1 + z −1
= 1 ⇔ K = 1 − e−π/5 HBil (z) = 0.2452 ·
1 − e−π/5 1 − 0.5095z −1
The transfer function of the filter is therefore There is a zero at z = −1 and a pole at z = 0.5095. See Figure 93 for the amplitude
1 − e−π/5 1 response in linear scale, in (power) desibels (20*log10(A)=10*log10(A 2 )), and the
H(z)Imp = = 0.4665 · pole-zero plot. Compare also to the filter obtained through the impulse-invariant
1 − e−π/5 z −1 1 − 0.5335z −1
method in Figure 92.
There is a pole at z = 0.5335, see Figure 92 for the amplitude response in linear
1
scale, in desibels and the pole-zero plot. 0
1

0.8
−10 0.5

Imaginary Part
1
1 0.6
0

(dB)
0.8 −20 0
0.4
−10 0.5

Imaginary Part
0.6 −30 −0.5
0.2
(dB)

−20 0
0.4 −40
0 −1
−30 0 100 200 300 400 500 0 100 200 300 400 500 −1 −0.5 0 0.5 1
−0.5 f (Hz) f (Hz) Real Part
0.2

0
−40
−1 (a) (b) (c)
0 100 200 300 400 500 0 100 200 300 400 500 −1 −0.5 0 0.5 1
f (Hz) f (Hz) Real Part
Figure 93: Problem 47, the filter HBil (z) using bilinear transform. (a) Amplitude response in
(a) (b) (c) linear scale and (b) in desibels, (c) pole-zero diagram.
Figure 92: Problem 47, the filter HImp (z) using impulse-invariant method. (a) Amplitude
response in linear scale |H(ejω )| and (b) in desibels 10 · log10 |H(ejω )|2 , (c) pole-zero diagram.

c) Transfer function using bilinear transform. Compute the normalized angular discrete-
time cut-off frequency ωc ,
2πΩc 2π2πfc 2πfc
ωc = = = = 0.2π
Ωs 2πfT fT
and the prewarped cut-off frequency Ωpc (k = 2/T ):
ωc
Ωpc = k · tan( ) = k · tan(0.1π)
2
The digital filter is obtained through bilinear transform:

H(z) = H(s)|s=k· 1−z−1 , Ωc =Ωpc =k·tan(0.1π)


1+z −1

Ωc
= | 1−z −1
s + Ωc s=k· 1+z−1 , Ωc =Ωpc =k·tan(0.1π)

k · tan(0.1π)
= 1−z −1
| 6k
k · 1+z −1 + k · tan(0.1π)

tan(0.1π)(1 + z −1 )
=
(1 + tan(0.1π)) − (1 − tan(0.1π))z −1

T-61.246 DSP 2005 103/140 SOLUTIONS T-61.246 DSP 2005 104/140 SOLUTIONS

48. Problem: Use windowed Fourier series method and design a FIR-type (causal) lowpass
filter with cutoff frequency 3π/4. Let the order of the filter be 4. 1 W (ejω)
r jω
Ht(e ) using rectangular window
5
1
Magnitude

a) Use the rectangular window of length 5. 4


0.8

b) Use the Hamming window of length 5. 3 0.6

c) Compare how the amplitude responses of the filters designed in (a) and (b) differ 2 0.4

assuming that the window size is high enough (e.g. M = 50). 1 0.2

π ω 0
0 0.2pi 0.4pi 0.6pi 0.8pi pi
0
0 0.2pi 0.4pi 0.6pi 0.8pi pi

Solution: Digital FIR filter design with windowed (truncated) Fourier series method. (a) (b) (c)
The idea is to find infinite-length impulse response of the ideal filter and truncate it so
Figure 95: Problem 48(a): frequency domain (0 . . . π), (a) Hd (ejω ), (b) Wr (ejω ), (c) Ht (ejω ).
that a realizable finite-length filter is obtained.

ht [n] = hd [n] · w[n] ↔ Ht (z) = Hd (z) ~ W (z) b) Now we are using Hamming window2 wh [n] of length 5,
(
Now, when cut-off frequency (-3 dB) is at ωc = 3π/4, the infinite-length impulse response 0.54 + 0.46 cos(2πn/4), −2 ≤ n ≤ 2
of the ideal filter is: wh [n] =
3π 3 0, otherwise
hd [n] = sin( n)/(πn) = (3/4) sinc( n)
4 4
Hence,
When computing values, sin(x)/x → 1, when x → 0, or sinc(x) → 1, when x → 0. So,
we get hd [n] = {. . . , −0.1592, 0.2251, 0.75, 0.2251, −0.1592, . . .}. 
ht [n] = hd [n] · wh [n] = hd [n] · 0.54 + 0.46 cos(2πn/(2M ))
a) Now we are using rectangular window wr [n] of length 5 (4th order), = {0.08 · (−0.1592), 0.54 · 0.2251, 0.75, 0.54 · 0.2251, 0.08 · (−0.15592)}
( = {−0.0127, 0.1215, 0.75, 0.1215, −0.0127}
1, −2 ≤ n ≤ 2
wr [n] = If causal filter is needed, then
0, otherwise
hc [n] = ht [n − 2] = {−0.0127, 0.1215, 0.75, 0.1215, −0.0127}
Hence, In Figure 96 time-domain view:
(a) hd [n], (b) wh [n], and (c) ht [n] = hd [n] · wh [n].
ht [n] = hd [n] · wr [n] = {−0.1592, 0.2251, 0.75, 0.2251, −0.1592} In Figure 97 the corresponding frequency-domain view:
(a) Hd (ejω ), (b) Wh (ejω ), and (c) Ht (ejω ) = Hd (ejω ) ~ Wh (ejω ).
If causal filter is needed, then the shift by two is needed
hc [n] = ht [n − 2] = {−0.1592, 0.2251, 0.75, 0.2251, −0.1592}. Ideal LP wc = 3 π/4 → hd[n], n ∈ (−10,..,10) Hamming window ht[n] using Hamming window

In Figure 94 time-domain view: 0.8 1 0.8

(a) hd [n] (IIR), (b) wr [n], and (c) ht [n] = hd [n] · wr [n] (FIR). 0.6 0.8 0.6

0.4 0.6 0.4


In Figure 95 the corresponding frequency-domain view:
0.4
(a) Hd (ejω ) (ideal, desired), (b) Wr (ejω ), and (c) Ht (ejω ) = Hd (ejω ) ~ Wr (ejω ) (real-
0.2 0.2

0 0.2 0
isable).
−0.2 0 −0.2

−10 −5 0 5 10 −4 −2 0 2 4 −4 −2 0 2 4
Ideal LP wc = 3 π/4 → hd[n], n ∈ (−10,..,10) Rectangular window ht[n] using rectangular window

0.8 1 0.8 (a) (b) (c)


0.8
0.6 0.6
Figure 96: Problem 48(b): time domain view, (a) hd [n], (b) wh [n],(c) ht [n].
0.4 0.6 0.4

0.2 0.4 0.2

0 0.2 0 c) Some examples of window functions:


−0.2 0 −0.2

−10 −5 0 5 10 −4 −2 0 2 4 −4 −2 0 2 4
i) Rectangular N =11, Figure 98
(a) (b) (c) ii) Rectangular N =65, Figure 99
iii) Hamming N =65, Figure 100
Figure 94: Problem 48(a): time domain view, (a) hd [n], (b) wr [n],(c) ht [n].
2
The expression is slightly different from that given in Section 7.6.4 in Mitra, but the same as in Matlab.
T-61.246 DSP 2005 105/140 SOLUTIONS T-61.246 DSP 2005 106/140 SOLUTIONS

jω jω jω
N = 65, |H (e )| = |H (e ) * W (e )|
t2 d 2
Rectangular−window w[n], N=65
1
1 jω
Wr(e )

Ht(e ) using Hamming window 0.8 1
2.5 1
0.6
Magnitude
0.4
2 0.8 0.8
0.2

0
1.5 0.6
−30 −20 −10 0 10 20 30 0.6

1 0.4 Rectangular−window W(ejω), N=65


1
0.4
0.8
0.5 0.2

ω
0.6

π
0.2
0 0 0.4
0 0.2pi 0.4pi 0.6pi 0.8pi pi 0 0.2pi 0.4pi 0.6pi 0.8pi pi

0.2
(a) (b) (c) 0
0 50 100 150 200 250 300 350 400 450 500
0
0 0.5 1 1.5 2 2.5 3 3.5 frequency, Hz

Figure 97: Problem 48(b): frequency domain (0 . . . π), (a) Hd (ejω ), (b) Wh (ejω ), (c) Ht (ejω ).

Figure 99: Rectangular window N = 65, see the text in Problem 48(c).
There are three figures for each item. Top left figure is the window function in time N=65, Hamming, |Ht3(ejω)| = |Hd(ejω) * W3(ejω)|

domain w[n]. The causal version can be obtained by shifting. Bottom left figure is 1
Hamming−window w[n], N=65
1

the window function in frequency domain W (ejω ). The third figure in right is the 0.8
0.9
0.6
amplitude frequency of actual filter which is obtained via window function method. 0.4
0.8

The desired lowpass filter Hd (ejω ) is drawn in dashed line, the implemented filter 0.2
0.7

Ht (ejω ) = Hd (ejω ) ~ W (ejω ) is solid line. The cut-off frequency is at 100 Hz, and
0 0.6
−30 −20 −10 0 10 20 30
0.5

the sampling frequency is 1000 Hz. 1


Hamming−window W(ejω), N=65
0.4

Notice that 0.8 0.3

0.6
0.2

i) Rectangular N =11 gives insufficient result. 0.4


0.1

ii) Rectangular N =65 gives sharp transition band but oscillates (Gibbs phenomenon). 0.2

0
0
0 50 100 150 200 250 300 350 400 450 500
0 0.5 1 1.5 2 2.5 3 3.5 frequency, Hz
iii) Hamming N =65 is flat both in passband and stopband but the transition band
is not as tight as in (ii).
Figure 100: Hamming window N = 65, see the text in Problem 48(c).
N=11, |Ht1(ejω)| = |Hd(ejω) * W1(ejω)|
Rectangular−window w[n], N=9
1 1

0.8

0.6
0.9
49. Problem: The following transfer functions H1 (z) and H2 (z) representing two different
0.4
0.8
filters meet (almost) identical amplitude response specifications
0.2 0.7

b0 + b1 z −1 + b2 z −2
0 0.6
−8 −6 −4 −2 0 2 4 6 8
0.5
H1 (z) =
1
Rectangular−window W(e ), N=9

0.4
1 + a1 z −1 + a2 z −2
0.8
0.3

0.6
0.2
where b0 = 0.1022, b1 = −0.1549, b2 = 0.1022, a1 = −1.7616, and
0.4
0.1 a2 = 0.8314, and
0.2
0 X12
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0 50 100 150 200 250
frequency, Hz
300 350 400 450 500
H2 (z) = h[k]z −k
k=0

where h[0] = h[12] = −0.0068, h[1] = h[11] = 0.0730,


Figure 98: Rectangular window N = 11, see the text in Problem 48(c).
h[2] = h[10] = 0.0676, h[3] = h[9] = 0.0864, h[4] = h[8] = 0.1040,
h[5] = h[7] = 0.1158, h[6] = 0.1201.
For each filter,

a) state if it is a FIR or IIR filter, and what is the order


b) draw a block diagram and write down the difference equation
c) determine and comment on the computational and storage requirements
d) determine first values of h1 [n]

T-61.246 DSP 2005 107/140 SOLUTIONS T-61.246 DSP 2005 108/140 SOLUTIONS

Solution: The transfer functions H1 (z) and H2 (z) have been designed using the same x[n]
amplitude specifications, see Figure 101. z −1 z −1 z −1

Amplitude response of H1(z) Amplitude response of H2(z)

h0 h1 h2 h12
0 0 y[n]
−10 −10

Figure 103: H2 (z) as a block diagram in Problem 49.


Power dB

Power dB

−20 −20

−30 −30

FIR IIR
−40 −40

Number of multiplications 13 5
−50
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
−50
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Number of additions 12 4
Angle ω * π (rad) Angle ω * π (rad)

Storage locations (coefficients and data) 26 10


|H1 (ejω )| |H2 (ejω )|

Figure 101: Amplitude responses of H1 (z) and H2 (z) in Problem 49. Table 10: Computational and storage requirements of H1 (z) and H2 (z).

d) A simple way to determine the impulse response is to insert an impulse x[n] = δ[n]
a) H1 (z) is IIR. There is a denominator polynomial. into input and compute recursively with difference equation what comes out in y[n].
H2 (z) is FIR. There is only the nominator polynomial. The registers are assumed to be zero in the initial moment. Another way to solve
b) H1 (z) is an IIR filter. In order to show the feedback in time domain one has to use first values of h1 [n] is to apply long division. Unfortunately, both cases are heavy by
inverse z-transform: hands. Inverse z-transform can be used in order to receive exact h[n]. Using Matlab,
Y (z) b0 + b1 z −1 + b2 z −1 h1 [n] = {0.1022, 0.0251, 0.0615, 0.0875, 0.1029, 0.1086, . . .}
= H(z) =
X(z) 1 + a1 z −1 + a2 z −1
 
Y (z) 1 + a1 z −1 + a2 z −1 = X(z) b0 + b1 z −1 + b2 z −1 | Z −1 {.}
y[n] + a1 y[n − 1] + a2 y[n − 2] = b0 x[n] + b1 x[n − 1] + b2 x[n − 2]

From the difference equation the block diagram can be drawn (Figure 102). Note
that the same coefficients can be found also in the form of H1 (z).

x[n] b0 y[n]

z −1 −a1 z −1
b1

z −1 z −1
b2 −a2

Figure 102: H1 (z) as a block diagram in Problem 49.

The impulse response h[n] of FIR filter H2 (z) is directly seen and its length is 13
(finite impulse response). The block diagram consists only of multipliers and delays
(Figure 103).
c) From examination of the two difference equations the computational and storage
requirements for both filters are summarized in Table 10.
It is evident that the IIR filter is more econimical in both computational and storage
requirements than the FIR filter. However, there are some tricks to improve FIR
filter structure (e.g. Sections 6.3.3., 6.3.4 in Mitra).
T-61.246 DSP 2005 109/140 SOLUTIONS T-61.246 DSP 2005 110/140 SOLUTIONS

50. Problem: Suppose that the calculation of FFT for a one second long sequence, sampled 51. Problem: Express the desimal number −0.3125 as a binary number using sign bit and
with 44100 Hz, takes 0.1 seconds. Estimate the time needed to compute (a) DFT of a one four bits for the fraction in the format of (a) sign-magnitude, (b) ones’ complement, (c)
second long sequence, (b) FFT of a 3-minute sequence, (c) DFT of a 3-minute sequence. two’s complement. What would be the value after truncation, if only three bits are saved.
The complexities of DFT and FFT can be approximated with O(N 2 ) and O(N log2 N ),
respectively. Solution: The binary number representation is discussed in Section 8.4 in Mitra. Now,
−0.3125 = −5/16. We can express it in fixed-point representation using a sign bit s and
Solution: FFT is a computationally effective algorithm for calculating the Discrete four bits for the fraction.
Fourier Transform (DFT) of a sequence(Section 8.3.2 in Mitra). The computational com- There are three different forms for negative numbers, for which all the sign bit is 0 for a
plexity of FFT is O(N log N ) where N is the length of the sequence. The complexity of positive number and 1 for a negative number.
the basic algorithm for DFT is quadratic to the input length i.e. O(N 2 ).
Here, it is supposed that the calculation of FFT for a one second long sequence, sam- a) Sign-magnitude format:P1∆ 0101.
pled with 44100 Hz, takes 0.1 seconds. Thus, the length of the sequence is N = 1 s × b-bit fraction is always bi=1 a−i 2−i . For a negative number s = 1:
44100 Hz = 44100 samples and we can approximate the number of operations needed S = −(0 · 2−1 + 1 · 2−2 + 0 · 2−3 + 1 · 2−4 ) = −0.3125.
for the calculation as N log2 N (using the base-2 logarithm). Since performing these b) Ones’ complement: 1∆ 1010.
operations takes 0.1 seconds, we get the (average) execution time for a single operation: P
Decimal number S = −s(1 − 2−b ) + bi=1 a−i 2−i . The negative number can also be
0.1 s achieved by complementing all bits of the corresponding positive value (+0.3125 ,
t= ≈ 147 ns 0∆ 0101 → 1∆ 1010 , −0.3125).
44100 log2 (44100)
S = −1(1 − 2−4 ) + (1 · 2−1 + 0 · 2−2 + 1 · 2−3 + 0 · 2−4 )
a) The time needed to compute DFT of a one second long sequence is estimated as the = −0.9375 + 0.625 = −0.3125
number of operations needed times the execution time for a single operation: c) Two’s complement: 1∆ 1011. P
2 2
Decimal number S = −s+ bi=1 a−i 2−i . It can also be achieved by complementing all
N t = 44100 × 147 ns ≈ 300 s ≈ 5 min bits and adding 1 to the least-significant bit (LSB) (+0.3125 , 0∆ 0101 → 1∆ 1010 +
1 = 1∆ 1011 , −0.3125).
b) A 3-minute sequence, sampled with 44100 Hz, consists of N 0 = 180 s × 44100 Hz = S = −1 + (1 · 2−1 + 0 · 2−2 + 1 · 2−3 + 1 · 2−4 )
7938000 samples. Calculating FFT for N 0 takes approximately: = −1 + 0.6875 = −0.3125
N 0 log2 (N 0 )t = 7938000 log2 (7938000) × 147 ns ≈ 30 s
The two’s complement is normally used in DSP chips.
c) Calculating DFT for N 0 takes approximately: After truncation

(N 0 )2 t = 79380002 × 147 ns ≈ 9 · 106 s ≈ 100 d a) 1∆ 0101 → 1∆ 01 , −0.25


b) 1∆ 1010 → 1∆ 10 , −0.25
It should be noted that these are only very crude approximations of the actual time it c) 1∆ 1011 → 1∆ 10 , −0.5
takes to calculate the FFT and DFT algorithms with different sizes of input sequences.
The O(·) notation omits all additive constants and constant coefficients of the complexity it can be seen that in this case truncation of (a) and (b) produced a bigger number,
and concerns only the asymptotic behavior of complexity when N grows without limit. but (c) a smaller. The analysis of quantization (truncation) process (Mitra, Section 9.1)
In addition, the length of N is assumed to be a power of 2 in FFT algoritms. results to quantization errors depicted in Problem 53.

T-61.246 DSP 2005 111/140 SOLUTIONS T-61.246 DSP 2005 112/140 SOLUTIONS

52. Problem: In the following Figure 104, some error probability density functions of the Z Z b 2

quantization error are depicted. 1 1
f(e) (a) σe2 = (e − me )2 f (e)de = e − (a + b) de
−∞ a 2 b−a
−∆/2 ∆/2 e
b  3
f(e) (b) 1 .1 1
= e − (a + b)
b−a 3 2
a
−∆/2 ∆/2 e

f(e) (c)
( 3  3 )
1 1 1 1
= b − (a + b) − a − (a + b)
−∆ ∆ e
3b−a 2 2
( 3  3 )
Figure 104: Problem 52: Error density functions, also at page 19. 1 1 1 1 1 1
= b− a − a− b
3b−a 2 2 2 2

(a) Rounding 1 1 1
= (b − a)3 = (b − a)2
(b) Two’s complement truncation 12 b − a 12
(c) Magnitude (one’s complement) truncation
is used to truncate the intermediate results. Calculate the expectation value of the quan- Computation of mean and variance for each tree cases in the exercise paper, (a) rounding,
tization error me and the variance σe2 in each case. (b) two’s complement truncation, and (c) magnitude truncation.

a) Rounding: a = − ∆2 , b = ∆
2
Solution: In this problem we are analysing different types of quantization methods. ∆
here means the quantization step, ∆ = 2−B . For example, if we are using (B +1) = (4+1) 1 ∆ ∆
bits and fixed-point numbers with two’s complement representation, possible 2B+1 = 32 me = (− + ) = 0
2 2 2
quantized values are
  2
{−1, −15/16, −14/16, . . . , 14/16, 15/16}. 1 ∆ ∆ ∆2
σe2 = − − =
The area (integral) of the propability density function f (e) is always one. All the dis- 12 2 2 12
tributions are uniform. Hence, f (e) (height of the box) of each pdf is easily computed.
b) Two’s complement truncation: a = −∆, b = 0
We first compute E[E] = me and Var[E] = E[(E − E[E])2 ] = σe2 for general uniform
distribution (see Figure 105). 1 ∆
me = (−∆ + 0) = −
2 2
f(e)
1/(b−a) 1 ∆2
σe2 = [0 − (−∆)]2 =
12 12
a b e
c) Magnitude truncation: a = −∆, b = ∆

1
Figure 105: Computing the mean and variance of general uniform distribution in Problem 52. me = (−∆ + ∆) = 0
2
 1 ∆2
 1 σe2 = [∆ − (−∆)]2 =
 a≤e≤b 12 3
f (e) = b−a

 0 e<a∨e>b
Z ∞ Z b b
1 1 .1 2
me = ef (e)de = e de = e
−∞ a b−a b−a 2
a

1 1 1 1 1
= (b2 − a2 ) = (b − a)(b + a) = (b + a)
2b−a 2b−a 2
T-61.246 DSP 2005 113/140 SOLUTIONS T-61.246 DSP 2005 114/140 SOLUTIONS

53. Problem: In this problem we study the roundoff noise in direct form FIR filters. Transfer functions from noise sources to the output are equal to unity. Total output
Consider an FIR filter of length N having the transfer function noise is thus
N
X −1

N −1 e[n] = ei [n] .
X
H(z) = h[k]z −k . i=0

k=0 The variance of the noise is


 
Sketch the direct form realization of the transfer function. 2
σe,tot = E e2 [n] − E[e[n]] 2
| {z }
a) Derive a formula for the roundoff noise variance when quantization is done before =0 (rounding)
 !2 
summations. N
X −1

b) Repeat (a) for the case where quantization is done after summations, i.e. a double =E ei [n]  [E[ei [n]ej [n]] = 0, i 6= j]
precision accumulator is used. i=0

N −1
X   NX−1
2−2B
= E e2i [n] = σe2 = N σe2 = N
Solution: Direct form realization of the filter. Quantization blocks are marked by Q in 12
i=0 i=0
Figure 106.
x[n]
b) The model, when quantization is done after summations, is drawn in Figure 108.
z −1 z −1 z −1
Now there is only one quantization point, i.e., there is only one noise source, e[n].

2 2−2B
h[0] h[1] h[N − 1] ⇒ σe,tot = σe2 = .
12

x[n]
Q Q Q
z −1 z −1 z −1
y[n]

h[0] h[1] h[N − 1]

Figure 106: Filter with finite wordlength in Problem 53. y[n]


Q

a) The roundoff noise model (ei [n]:s are error sources), when quantization is done before
summations, is depicted in Figure 107.
Figure 108: Filter with only one quantization point in Problem 53.
x[n]
z −1 z −1 z −1

h[0] h[1] h[N − 1]

y[n]

e0 [n] e1 [n] eN −1 [n]

Figure 107: Roundoff noise model with N quantization points in Problem 53.

It is assumed that the quantization is done using rounding. B + 1 bits are used in
the coefficient quantization (∆ = 2−B ):
2−2B
⇒ σe2 = , me = 0 for all ei [n], i = 0, . . . , N − 1.
12

T-61.246 DSP 2005 115/140 SOLUTIONS T-61.246 DSP 2005 116/140 SOLUTIONS

54. Problem: The quantization errors produced in digital systems may be compensated by Pole−zero−diagram of H(z)

1
error-shaping filters (Section 9.10 in Mitra). The error components are extracted from the
system and processed e.g. using simple digital filters. This way the noise at the output
0.5
of the system can be reduced.
Consider a lowpass DSP system with a second-order noise reduction system in Fig- 0
2

ure 109(a).
−0.5
a) What is the transfer function of the system if infinite wordlength is used?
b) Derive an expression for the transform of the quantized output, Y (z), in terms of −1
−1 −0.5 0 0.5 1
the input transform, X(z), and the quantization error, E(z), and hence show that
the error feedback network has no adverse effect on the input signal. Figure 110: The pole-zero plot of H(z) = (1+2z −1 +z −2 )/(1−1.75z −1 +0.81z −2 ) in Problem 54.
c) Deduce the expression for the error feedback function.
d) What values k1 and k2 should have in order to work as an error-shaping system?
After z-transform,

Solution: First-order and second-order feedback structures are introduced in Sections


h 1 + 2z −1 + z −2 i h 1 + k z −1 + k z −2 i
1 2
Y (z) = X(z) + E(z)
9.10.1 and 9.10.2 in Mitra. Consider first the block diagram shown in Figure 109(a) and 1 − 1.75z −1 + 0.81z −2 1 − 1.75z −1 + 0.81z −2
its round-off noise model in Figure 109(b). = H(z)X(z) + He (z)E(z)
z−1 z−1 z−1 z−1
It can be observed that the noise transfer function He (z) modifies only the quanti-
k2 k1
e[n]
k2 k1 zation error.
e[n]
−1 c) The noise transfer function is

x[n] y[n] x[n] y[n] 1 + k1 z −1 + k2 z −2


Q He (z) = = Heu (z) Hes (z)
1 w[n] 1 w[n] 1 − 1.75z −1 + 0.81z −2
z−1 z−1 z−1 z−1
Notice that without error-shaping feedback structure, i.e., k1 = 0 and k2 = 0, the
noise transfer function is (u = unshaped)
2 1.75 2 1.75
z−1 z−1 z−1 z−1
1
Heu (z) =
1 − 1.75z −1 + 0.81z −2
1 −0.81 1 −0.81
(a) (b) So, the error-feedback circuit is actually shaping the error spectrum by (s = shaping)
Figure 109: (a) Second-order direct form I system with second-order noise reduction, (b) and
Hes (z) = 1 + k1 z −1 + k2 z −2
its noise model in Problem 54.
d) Without error-shaping the quantized output spectrum is
a) If infinite precision is used, the quantization is not needed and e[n] ≡ 0 (see Fig- Yu (z) = H(z)X(z) + Heu (z)E(z)
ure 109(b) with e[n] = 0). In that case, the system function is
Error-shaping filter Hes (z) should efficiently discard the effects of the poles of Heu (z).
1 + 2z −1 + z −2
H(z) = Error-feedback coefficients are chosen to be simple integers or fractions (ki = 0, ±0.5, ±1, ±2),
1 − 1.75z −1 + 0.81z −2 so that the multiplication can be performed using a binary shift operation and it
Computing zeros and poles we get a pole-zero diagram from which it can be derived will not introduce an additional quantization error. Choosing k1 = −2, k2 = 1,
that the filter is lowpass (Figure 110). Hes (z) = 1 − 2z −1 + z −2 is a highpass filter with two zeros at z = 1.
b) From Figure 109(a) it can be obtained the following difference equations: The error shaping structure lowers the noise in the passband by pushing it into the
stopband of the filter (see Figure 9.45 in Mitra).
e[n] = y[n] − w[n]
w[n] = (x[n] + 2x[n − 1] + x[n − 2])
+ (1.75y[n − 1] − 0.81y[n − 2])
+ (k1 e[n − 1] + k2 e[n − 2])
T-61.246 DSP 2005 117/140 SOLUTIONS T-61.246 DSP 2005 118/140 SOLUTIONS

1
55. Problem: Consider a cosine sequence x[n] = cos(2π(f /fs)n) where f = 10 Hz and 0.6 Image fs 0.6 ωs/2

fs = 100 Hz as depicted in the top left in Figure 111. While it is a pure cosine, its 0.5
0.5 0.5

spectrum is a peak at the frequence f = 10 Hz (top middle) or at ω = 2πf /fs = 0.2π 0.4 0.4

xu[n] = x[n/2]
0 0.3 0.3
(top right).
0.2 0.2

−0.5
0.1 0.1
a) Sketch the output sequence xu [n] and its spectra using up-sampler with up-sampling 0 0
factor L = 2. −1
0 0.05 0.1 0.15 0.2 0 50 100 150 200 0 pi 2pi

b) Sketch the output sequence xd [n] and its spectra using down-sampler with factor Figure 112: Problem 55(a). Up-sampled signal xu [n], factor L = 2. The sampling frequency is
M = 2. increased to 200 Hz, and there is an image spectrum.

x[n] = cos(2 π 10/100 n)


Solution: Sometimes it is necessary or useful to change the sampling frequency fs . 1
f = 100 Hz
s
Consider music formats DAT (48 kHz) and CD (44.1 kHz).

x[n]
0

x[n] = cos(2 π 10/100 n) |X(ej ω)|, Hz |X(ej ω)|, ω x π −1


0 0.05 0.1 0.15 0.2
1 1
fs ω /2 T = 0.0111 s, f = 90 hz
0.6 0.6 s 2 2 f = 200 Hz
s

x [n]
0

u
0.5 0.5
0.5
T = 0.1 s, f = 10 hz
−1 1 1
0.4 0.4

1
x[n]

0 0.3 0.3
f = 200 Hz
s

[n]
0

uLP
0.2 0.2

x
−0.5
0.1 0.1 −1
Upsampled and LP−FILTERED (image filtered out), x [n]
uLP
0 0
−1
0 0.05 0.1 0.15 0.2 0 50 100 150 200 0 pi 2pi
Figure 113: A closer look at up-sampling. Top, original sequence. Middle L = 2, L − 1 = 1
zeros added between the original samples. Bottom, using (ideal) LP-filter to remove the image,
Figure 111: Problem 55(a). The original sequence of a cosine of f = 10 Hz and its spectrum.
i.e., 90 Hz component. The continuous curve is plotted only for better visual view. See the
The angular frequency ω = 2π(f /fs ) = 2π(10/100) = 0.2π.
text in Problem 55(a).

a) Up-sampling with factor L = 2. In the time domain there will be L−1 zeros between b) Down-sampling with factor M = 2 means taking only every second sample.
the original samples, see Figure 112(a).
xd [n] = x[nM ] = x[2n]
(
x[n/L], n = 0, ±L, ±2L, . . .
xu [n] = A possible effect is losing information. However, in this case, this does not occur
0, otherwise because f = 10 Hz < fs,new /2 = 25 Hz. See Figure 114(a).
(
x[n/2], n = 0, ±2, ±4, . . . In the frequency domain the sampling frequency is decreased to 50 Hz. See Fig-
= ures 114(b)-(c).
0, otherwise M −1
1 X
Xd (ejω ) = X(ej(ω−2πk)/M )
In the frequency domain the sampling frequency is multiplied by L, hence, the new M k=0
sampling frequency is 200 Hz. L − 1 images from the original spectrum are emerged
equivalently between 0 and fs,new . 1
0.6 0.6

Xu (ejω ) = X(ejωL ) = X(ej2ω ) 0.5


0.5 0.5

0.4 fs 0.4 ωs/2

xd[n] = x[2n]
Each cosine is a peak pair (±f ) in the spectrum. The original peaks are at f = 10 0 0.3 0.3

and f = 200 − 10 = 190 Hz, and after up-sampling new images at f = 90 and −0.5
0.2 0.2

0.1 0.1
f = 110 Hz, as shown in Figure 112(b). The same with angular frequencies is shown 0 0
in Figure 112(c). −1
0 0.05 0.1 0.15 0.2 0 50 100 150 200 0 pi 2pi

Notice that if you ideally convert the sequence xu [n] into continuous-time xu (t) you Figure 114: Problem 55(b). Down-sampled signal xd [n], factor M = 2. The sampling frequency
will find also a high frequency component, an image component. Normally images is decreased to 50 Hz.
are filtered out using a lowpass filter (see anti-imaging and anti-aliasing filters). See
Figure 113.

T-61.246 DSP 2005 119/140 SOLUTIONS T-61.246 DSP 2005 120/140 SOLUTIONS

56. Problem: Express the output y[n] of the system shown in Figure 115 as a function of 57. Problem: Show that the factor-of-L up-sampler xu [n] and the factor-of-M down-sampler
the input x[n]. xd [n] defined as in Problem 55 are linear systems.

x[n] v[n] vu [n]


↓2 ↑2 Solution: First, consider the up-sampler. Let x1 [n] and x2 [n] be two arbitrary inputs
with y1 [n] and y2 [n] as the corresponding outputs. Now,

z −1 z −1 x1 [n/L] : n = 0, ±L, ±2L, . . .
y1 [n] =
0 : otherwise
w[n] wu [n] y[n]

↓2 ↑2 x2 [n/L] : n = 0, ±L, ±2L, . . .
y2 [n] =
0 : otherwise
Figure 115: Multirate system of Problem 56.
Let us now apply the input x3 [n] = αx1 [n] + βx2 [n] with the corresponding output y3 [n]
as
Solution: Consider an input signal x[n] with the corresponding z-transform X(z). After 
factor-of-L up-sampling, the z-transform of the signal xu [n] is αx1 [n/L] + βx2 [n/L] : n = 0, ±L, ±2L, . . .
y3 [n] =
0 : otherwise
 
Xu (z) = X(z L ) αx1 [n/L] βx2 [n/L] : n = 0, ±L, ±2L, . . .
= +
0 0 : otherwise
and after factor-of-M down-sampling, the z-transform of the signal xd [n] is
= αy1 [n] + βy2 [n]
M −1
1 X −k Thus, the up-sampler is a linear system.
Xd (z) = X(z 1/M WM )
M k=0
Now, consider the down-sampler with the inputs x1 [n] and x2 [n] and the corresponding
outputs y1 [n] and y2 [n]. Now, y1 [n] = x1 [nM ] and y2 [n] = x2 [nM ]. By applying the input
where WM = e−j2π/M . See Section 10.1.2 in Mitra for the derivation of these equations.
x3 [n] = αx1 [n] + βx2 [n] we get the corresponding output y3 [n] = x3 [nM ] = αx1 [nM ] +
Using these equations, let us derive the z-transforms of the intermediate signals v[n], vu [n], βx2 [nM ]. Hence, the down-sampler is also a linear system.
w[n], and wu [n] and finally the z-transform of the output y[n]. Let us denote the delayed
It should also be noted, that both the up-sampler and the down-sampler are time-varying,
version of the input as X 0 (z) = z −1 X(z). Furthermore, note that W2−1 = ej2π/2 = −1.
i.e. not LTI systems.
1
1X 1 1
V (z) = X(z 1/2 W2−k ) = X(z 1/2 ) + X(−z 1/2 )
2 k=0 2 2
1
1 X 0 1/2 −k 1 1
W (z) = X (z W2 ) = z −1/2 X(z 1/2 ) − z −1/2 X(−z 1/2 )
2 2 2
k=0

1 1
Vu (z) = V (z 2 ) = X(z) + X(−z)
2 2
1 1
Wu (z) = W (z 2 ) = z −1 X(z) − z −1 X(−z)
2 2
Y (z) = z −1 Vu (z) + Wu (z) = z −1 X(z)

or y[n] = x[n − 1] in time-domain (derive the same in time-domain!).


T-61.246 DSP 2005 121/140 SOLUTIONS T-61.246 DSP 2005 122/140 TERMINOLOGY

58. Problem: Consider the multirate system shown in Figure 116 where H0 (z), H1 (z), and Terminology
H2 (z) are ideal lowpass, bandpass, and highpass filters. Sketch the Fourier transforms
of the outputs y0 [n], y1 [n], and y2 [n] if the Fourier transform of the input is as shown in In order to learn more about DSP some terms should be clear.
Figure 117(a).
termi term description example source
aaltomuoto
Solution: First, let us denote the down-sampled signal as xd [n] and the again up-sampled
signal as xu [n], shown in Figure 116.
aikainvarianttisuus
y0 [n]
H0 (z)

x[n] xd [n] xu [n] y1 [n] aikataso


↓3 ↑3 H1 (z)

H2 (z)
y2 [n] alipäästösuodin

amplitudi-
Figure 116: The multirate system in Problem 58.
modulaatio

The corresponding Fourier transforms (spectra) Xd (z) and Xu (z) are as follows (notice amplitudivaste
the reduced amplitude) in Figure 117.
X(ejω ) Xd (ejω ) Xu (ejω )

1 1 1
analoginen
3 3

0
0 π/3 2π/3 π
ω 0
0 π 2π
ω 0
0 π 2π
ω analyysiyhtälö analysis lasketaan signaalista x[n] ak P = [1,
equation F-sarjan kertoimet ak (1/N ) n x[n]e−jkω0 n s.213]

Figure 117: Original, upsampled and downsampled spectrum in Problem 58. BIBO-
stabiilisuus
Now, the Fourier transforms of the outputs Y0 (z), Y1 (z), and Y2 (z), are obtained by
(ideally) filtering Xu (z). The output spectra are in Figure 118.
Boden dia-
H0 (ejω ) H1 (ejω ) H2 (ejω ) grammi
1 1 1

dekonvoluutio
0 ω 0 ω 0 ω
0 π/3 2π/3 π 0 π/3 2π/3 π 0 π/3 2π/3 π
Y0 (ejω ) Y1 (ejω ) Y2 (ejω )

1
3
1
3
1
3 desibeliasteikko

0 ω 0 ω 0 ω
0 π/3 2π/3 π 0 π/3 2π/3 π 0 π/3 2π/3 π digitaalinen

Figure 118: Bandpass filters in top row, and corresponding Output spectra in bottom row in cont.
Problem 58.

T-61.246 DSP 2005 123/140 TERMINOLOGY T-61.246 DSP 2005 124/140 TERMINOLOGY

cont. cont.
termi term description example source termi term description example source
diskreettiaikainen impulssijuna

duaaliominaisuus impulssivaste

P
FIR finite itseisesti sum- absolutely S= k |h[k]| < ∞ Jos impulssivaste [3,
(length) mautuva summable h[n] on itseisesti Ch2,
impulse summautuva, niin kalvo
response ko LTI-suodin on 17]
Fourier-kerroin stabiili.
jakso

Fourier-
muunnos jaksollisuus

Fourier- jatkuva-aikainen
muunnostaulukko

Fourier-sarja järjestelmä

geometrisen sar- kaskaadikytkentä


jan summa

harmoniset kom- kausaalisuus


ponentit

Hertz Hertz taajuuden yksikkö, 1/s Kosini värähtelee 4 keskiarvoistava moving aver-
kertaa sekunnissa, suodin age filter
f = 4 Hz
ideaalisuodin kompleksiarvoinen
funktio

IIR konvoluutio

ikkunafunktio Hamming, Hanning, konvoluutio-


Blackman, ..., kts. ominaisuus
help hamming Mat-
labissa käänteinen
cont. Fourier-
muunnos

cont.
T-61.246 DSP 2005 125/140 TERMINOLOGY T-61.246 DSP 2005 126/140 TERMINOLOGY

cont. cont.
termi term description example source termi term description example source
kääntyvyys nousuaika raise time

Laplace- parillinen sig-


muunnos naali

laskostuminen folding pariton signaali

lineaarikombinaatio perusjakso

lineaarinen peruskulmataajuus
vakiokertoimi-
nen differenssiy-
htälö perustaajuus
lineaarisuus

pitopiiri (N:n as-


lohko/virtauskaavio teen)

rajataajuus
LSI-suodin linear tarkoittaa samaa kuin
and shift- LTI, joskus “lineaarinen
invariant ja siirtoinvariantti” RC-piiri
filter
LTI-suodin
rekursiivinen
suodin
magnitudivaste
rinnankytkentä

muistirekisteri
ryhmäviive

näyteväli
sekvenssi

näytteenotto-
taajuus signaali

näytteenotto-
teoreema cont.

cont.

T-61.246 DSP 2005 127/140 TERMINOLOGY T-61.246 DSP 2005 128/140 TERMINOLOGY

cont. cont.
termi term description example source termi term description example source
signaalin aikasi- syöte
irto

taajuus
signaalin energia

taajuustaso frequency do- signaali tai järjestelmä


signaalinkäsittely- signal pro- systeemi, joka ottaa syöt- esim. LTI-suodin, (muunnostaso) main (trans- muunnettuna taajuus-
järjestelmä cessing teen x[n] ja palauttaa vas- joka voidaan kuvata form d.) tasoon esim. Fourier-
system teen y[n] impulssivasteella muunnoksella, tutkitaan
h[n] taajuuden funktiona, kts.
sinc-funktio aikataso
taajuusselektiivinen
suodin
sinusoidi
taajuusvaste

spektri
ulostulo

spektrogrammi
vaihevaste

stabiilisuus
vaste

suodattaminen
vierastuminen aliasing

suodin “When you think


about it, everything viive-elementti
is a filter.”[3, What_
is_Filter.html]
suotimen yksikköaskelfunktio
asteluku

yksikköimpulssi- unit impulse δ[n] = 1, kun n = 0, Lukujono {2, 1, 3} [1,


superpositio funktio function muuten δ[n] = 0 on x[n] = 2δ[n + s.30]
1] + δ[n] + 3δ[n − 1]
.
synteesiyhtälö

.
cont.

cont.
T-61.246 DSP 2005 129/140 TERMINOLOGY T-61.246 DSP 2005 130/140 TERMINOLOGY

cont. cont.
termi term description example source termi term description example source
. .

. .

. .

. .

. .

T-61.246 DSP 2005 131/140 MATLAB T-61.246 DSP 2005 132/140 MATLAB
cont.

Matlab Matrix calculations can be made if the dimensions are proper.


t*y % error, dimensions do not hold [1x4]*[1x4]
Matlab is a language for technical computing3 . It is widely used in the industry as well as in
t.*y % itemwise multiplication, [1x4].*[1x4]=[1x4]
the academic world. Here at HUT Matlab is available for students and researchers in Unix and
t*y’ % inner product, ’ == (complex conjugate) transpose, [1x4]*[4x1]=[1x1]
Windows networks. Unfortunately, there are not any off-line student versions available, but
t’*y % outer product, [4x1]*[1x4]=[4x4]
there is a free GNU Octave4 , which is mostly compatible with Matlab.
You can find the size of the matrix using size(A) and the length of the vector using length(y).
Matlab provides basic operations for scalar, vectors or matrices, as well as for real and complex
How to Read numbers, e.g. exp(j*pi), cos(3.14), sqrt(25), ... (see Table ??).
This is basically a short reference for using Matlab in digital signal processing. This is not a
tutorial. There are Matlab demo exercises in the autumn course that explain a lot more. These Scripts and functions
and a lot more can be found in http://www.cis.hut.fi/Opinnot/T-61.246/Matlab/.
Probably the best help can be found from Matlab itself. It contains all information on the Scripts and functions are both Matlab files ending with .m. They have slight but important
commands and lots of examples and tutorials. There are some functions listed in a section from differences althought they look like similar. You can add any comments to your files after %
Page 134. sign.
A script is a set of commands executed in a batch. The variables are found in the Matlab
Workspace. Consider a script, which draws a circle with red color on the screen. The following
Using Matlab at HUT lines are in a file called drawcircle.m.
The newest version of Matlab is Matlab 7. There are lots of graphical user interfaces and helps, w = [0 : pi/64 : 2*pi];
but all commands can be written also in the prompt in Command Window. Matlab provides C = exp(j*w); % i and j are both imaginary units in Matlab
excellent help pages with several examples. Type help function in order to get a quick help plot(real(C), imag(C),’r’); % ’r’ == red color
for the operation of the function function.
The script is called from Command Window by drawcircle, i.e. without the extension .m.
When working in Unix environment, start by typing use matlab and open Matlab then with
matlab. Listening of sound files may not work directly inside Matlab, but you have to write >> clear % removes all variables in Matlab Workspace
them to a WAV format (wavwrite) and listen with a player in Unix. The command exit >> whos % --> no variables
terminates the session. >> drawcircle % executes commands and draws a circle on screen
You should write down all your code into a file, which can be re-run or modified later. Use >> whos % --> variables C and w available!
the Matlab editor, which can be opened by typing edit in Command Window. Save your files A function may receive input variables and produce output variables which are seen only in
in the subdirectory Z:\MYDSP\ (or corresponding) in Windows Network and set your Current the memory area of the function.The first line of the function starts with a word function
Directory (a box containing a directory path in top of Matlab Window) to point to the same and contains names of input and output variables. Consider an example on a function which
directory. computes the angle in degrees. The filename for the function is getdeg.m and contains:
function [deg] = getdeg(z)
Basic Elements and Operations % GETDEG computes the angle of the complex number z = x + yj in degrees
Basic elements and operations are introduced in Matlab exercise I. Matlab operates with ma- x = real(z);
trices of different sizes. By typing: y = imag(z);
deg = 180 * atan(y/x) / pi;
A = [3 -2 1 1 5; 2 4 0 -1 -3; 5 5 9 -2 -4] If several input or output arguments, they are listed with the comma (,) seperator. The second
we get a matrix of size N ×M , where N is the number of rows and M is the number of columns. line (and adjacent %lines) are printed when help getdeg.
The function is called from Command Window with getdeg
A = >> clear % removes all variables in Matlab Workspace
3 -2 1 1 5 >> whos % --> no variables
2 4 0 -1 -3 >> z1 = 3 + 4*j; % a complex-valued z1
5 5 9 -2 -4 >> [degrees] = getdeg(z1);
We can easily get vectors with colon notation or by picking numbers from a matrix: >> whos % --> variables z1 and degrees available, but no x, y nor deg
Somehow a function is a safer way to work because variables cannot be changed anywhere else
t = [3 : 0.5 : 4.5] % [start : interval : end] but in the code. Assume that you have used a variable j as a counter, and its value is now
y = A(2, 2:5); % second row, columns 2 to 5 100. Then if you run drawcircle.m you will not get a circle while C = exp(100*w);! On the
% no feedback on the screen if semicolon (;) in the end of line other hand, reading an array of numbers from a file to Matlab workspace is useful to do only
3
http://www.mathworks.com once, not in a function that is called 100 times. In this case an array is read and then a script
4
http://www.octave.org is used or the variable is given into a function as an input.
T-61.246 DSP 2005 133/140 MATLAB T-61.246 DSP 2005 134/140 MATLAB

Error messages Some Matlab Commands


If a syntax error occurs, it is informed in red color with the line and column. Often an error .
is easily found. Typical errors are a wrong number or type of parentheses, a comma instead General commands and notations
of a dot, small/CAPITAL letter instead of CAPITAL/small, wrong number of arguments for a quit, terminates Matlab session
function, etc. help, lists all function directories available
Sometimes a logical error happens, which means that no error messages are reported but the help function, gives help on function, e.g. input arguments
code does not work as hoped. If scripts are used, one can remove all variables by clear all, type function, shows the code of function, which are not build-in
and try to run the code again. pause, waits until the user presses any key
pause(s), waits s seconds
Plotting and Printing more, pauses scrolling
who or whos, lists all variables
Basic plotting and printing commands are introduced in Matlab exercise I. Matlab provides diary, copies user commands into a file
easy tools for plotting figures. The basic command is plot, normally with two inputs X and ver, lists all toolboxes (versions) available
Y. It is nice that you add labels and titles for each figures, grid on, title, xlabel, legend, ! OS-command, calls command in operating system
colorbar, colormap, etc. %, starts the comment till the end of line
You can print your figure directly from the Matlab window, but it is probably nice to export it ;, does not print anything on screen
into a file. Depending on which operating system you are using: disp, prints strings of text nicely
File I/O
print -dmeta myfig.emf % Windows Metafile for Word load, opens a MAT binary file containing variables
print -dpng myfig.png % Portable Network Graphics for web browsers save, saves the variables into a MAT binary file
print -deps myfig.eps % Encapsulated PostScript for LaTeX textread, reads a formatted text file into Matlab workspace
dlmread, reads a formatted file of numbers into Matlab workspace
Signal Processing Toolbox fopen, opens a file
fclose, closes a file
All the commands related to Signal Processing Toolbox can be found by typing help signal.
fprintf, writes into a file
There are some nice demos, e.g. a DTMF demo with phone, and some GUI tools like sptool
fprintf(1,’...’), writes into a file handle 1 = on screen
(Matlab exercise II).
Useful commands
Digital signal is represented as a vector in Matlab. For example, x[n] = 2δ[n] − 3δ[n − 2] can
size, gives dimensions of the matrix (vector)
be written using the coefficients x = [2 0 -3]. An audio signal can be read with [x, fs,
length, gives the length of the vector
nbits] = wavread(’Z:\MYDSP\audio.wav’); Audio vectors can be exported with wavwrite.
fliplr, flipud, flips the order of items in an array, x[n] → x[−n]
An impulse response sequence h[n] = δ[n] − δ[n − 4] is expressed by h = [1 0 0 0 -1]. A
[xstart : interval: xstop], creates a vector starting from xstart
digital filter H(z) = B(z)/A(z) is represented in Matlab using the coefficients of the numerator
linspace, creates a vector similarly to [* : * : *] notation
polynomial B(z) and that of the denominator polynomial A(z). For example, in case of second-
Elemenary functions
order IIR filter H(z) = (1 − z −2 )/(1 + 0.81z −2 ), the vectors and some analysis functions are
exp, cos, sin, atan, sqrt, log, log10, ...
B = [1 0 -1]; % coefficients of B(z) in H(z)=B(z)/A(z) abs, absolute value of a complex number, e.g. |H(ejω )|
A = [1 0 0.81]; % coefficients of A(z) in H(z)=B(z)/A(z) angle, angle of a complex number, e.g. ∠H(ejω )
figure(1); freqz(B, A); % amplitude and phase responses real, real part of a complex number
figure(2); zplane(B, A); % pole-zero plot imag, imaginary part of a complex number
figure(3); impz(B, A); % impulse response roots, calculates roots of a polynomial
sum, sums elements column-wise
In Matlab II there are examples on computing the spectrum and spectrogram of the signal. Plotting figures
There are also demos on analyzing a LTI system and filtering. Examples on filter design plot, plots continuous signals
(system synthesis) can be found in Matlab III. An important part here is to scale the frequencies stem, plots sequences
correctly between [0 . . . 1]: clf, clears the current figure
cla, clears the current axis
fc fc,M atlab 3500 Hz fc,M atlab shg, the active window is brought on top
= Example: = ⇒ fc,M atlab = 0.35
fT 2 20000 Hz 2 close all, closes all windows
subplot, creates several axis in a window
grid on, inserts a grid on figure
title, title for a figure

T-61.246 DSP 2005 135/140 MATLAB T-61.246 DSP 2005 136/140 MATLAB

xlabel, title for x-axis Design an elliptic IIR lowpass filter with cut-off 0.3π
ylabel, title for y-axis and plot the frequency response |H(ejω )| and a pole zero 0

−20

diagram.

Magnitude (dB)
legend, creates a legend for a figure −40

−60

axis, zoom the axis, axis([xmin xmax ymin ymax]) −80

print, exports a figure into a file or prints it to a printer Wp = 0.3; Ws = 0.36; −100
0 1000 2000 3000 4000 5000
Frequency (Hz)

get, gets values of an object, e.g. p = plot(..); get(p) Rp = 0.5; Rs = 40; 0

set, sets values of an object, e.g. p = plot(..); set(p,’LineWidth’,2) [N, Wn] = ellipord(Wp, Ws, Rp, Rs); −100
Phase (degrees)

Commands for audio [B, A] = ellip(N, Rp, Rs, Wn); −200

soundsc or sound, plays a vector as sound (sc = scaled) freqz(B, A); −300

−400

wavread, reads a WAV file into Matlab zplane(B, A); 0 1000 2000 3000
Frequency (Hz)
4000 5000

wavwrite, writes a WAV file from Matlab


Design a FIR filter, cut-off at 3300 Hz and fT = 16 kHz, 1

DSP functions, see Signal Processing Toolbox 0.8

with Hamming window of order 15, plot the frequency


fft, fast Fourier transform 0.6

response |H(ejω )|. 0.4

ifft, inverse Fourier transform 0.2


Imaginary Part

dftmtx, computes a matrix W for DFT Wp = 3300 / (16000/2); 0

−0.2

unwrap, eliminates jumps in phase angles N = 15; −0.4

conv, linear convolution of two sequences [B, A] = fir1(N, Wp, hamming(N+1)); −0.6

conv, polynomial multiplication [H, w] = freqz(B, A, 1024, 16000);


−0.8

−1

filter, filters signal x with a filter given plot(w, abs(H)); −1 −0.5 0


Real Part
0.5 1

impz, impulse response for a discrete-time finite-dimensional system


freqz, draws frequence response, magnitude and phase response
zplane, plots a pole-zero-diagram
residuez, partial-fraction expansion of z-trasform H(z)
tf2zp, converts transfer function to corresponding zeros and poles
tf2sos, converts transfer function to corresponding set of second-order systems
buttord, cheb1ord, ellipord, etc., estimates the minimum order for fulfilling specifications
butter, cheby1, ellip, etc., computes filter coefficients
fir1, one of FIR filter design procedures, window method
remez, one of FIR filter design procedures, Parks-McClellan

Some Matlab Examples


Read an audio file, plot and listen to it.
0.5
[y, fs, nbits] = wavread(’vowel_o.wav’);
M = length(y);
t = [0 : M-1]/fs; 0

plot(t, y); grid on;


title(’My vowel /o/’); xlabel(’time (s)’); −0.5
axis([0.1 0.14 -0.8 0.8]);
soundsc(y, fs); 0.12 0.13 0.14


Compute a FFT X(e ) from the whole sequence and 300
plot the spectrum.

yF = fft(y); 200
M = length(yF);
w = fs * [0 : M-1]/M; 100
plot(w, 20*log10(abs(yF))); grid on;
title(’Spectrum’); xlabel(’freq. (Hz)’); 0
set(gca, ’XLim’, [0 fs/2]); 0 2000 4000
T-61.246 DSP 2005 137/140 LATEX T-61.246 DSP 2005 138/140 FORMULAS

LATEX Formulas
Next LATEX system is introduced through an example. You should have a Linux/Unix computer Z-transform
or then a Windows version called MiKTeX5 . Additionally, Matlab is required to end the outputs. ∞
X
Download the files from the course web page http://www.cis.hut.fi/Opinnot/T-61.246/ X(z) = x[n]z −n
LaTeX/ one by one or then in a zipped file all.zip. Save them into a subdirectory in your n=−∞
Linux/Unix system, say, ~myaccount/DSPLaTeX/. Now there should be at least the following
files: mydsp.tex, problem1.m. TKLHLSDF Summary of some important z-transform pairs and properties
Start by typing
kosh % mkdir DSPLaTeX Discrete-time function Z-transform ROC
kosh % chmod 700 DSPLaTeX
kosh % cd DSPLaTeX Unit impulse δ[n] 1 all z
kosh DSPLaTeX % latex mydsp
You will receive lots of text on screen beginning with This is TeX, Version 3.14159 (Web2C 1
Unit step µ[n] |z| > 1
7.3.7x) or similar. You will also get an error message informing that the file xxx.eps is 1 − z −1
missing. You can press CONTROL-C and Q.
1
Open Matlab and change the working directory to ~myaccount/DSPLaTeX/ in top of figure or Exponential an µ[n] |z| > |a|
by typing cd myaccount/DSPLaTeX. Then run the program problem1.m by typing problem1. 1 − az −1
You can read and edit the file using Matlab’s editor, which you can open with edit. The
1 − b cos(θ)z −1
programs contains the code for XXXX The line “print” in the file exports the figure with a Damped cosine wave bn cos(θn)µ[n] |z| > |b|
1 − 2b cos(θ)z −1 + b2 z −2
curve into the file XXX0 in Encapsulated PostScript format (.eps).
Let us assume that you have finished your work with Matlab. Return back to Unix. Now you b sin(θ)z −1
should have all files needed. Start LateX again. Damped sine wave bn sin(θn)µ[n] |z| > |b|
1 − 2b cos(θ)z −1 + b2 z −2
kosh DSPLaTeX % latex mylatexfile
Linear combination ax[n] + by[n] aX(z) + bY (z)
kosh DSPLaTeX % latex mylatexfile
kosh DSPLaTeX % xdvi mydsp.dvi
Time shift x[n ± n0 ] z ±n0 X(z)
After very first run, After second cross-references are set up.
Then you can convert... z 
Exponential weighting an x[n] X
kosh DSPLaTeX % dvips mydsp.dvi a
kosh DSPLaTeX % pdflatex mydsp.tex
dX(z)
Linear weighting nx[n] −z
Now from the first one you get a PostScript (read with ghostview or equivalent) and a PDF dz
(acroread).
You can see the file and uncomment several : tableofcontents and bibliography which uses the Convolution x[n] ~ y[n] X(z)Y (z)
bib file.
I
If you are using Bibliogrpha. You have to now run bibtex and then twice latex This will create 1  z  dv
Product x[n]y[n] X(v)Y
. 2πj C v v
kosh DSPLaTeX % latex mydsp Even x[n] = x[−n] Real X(ejω )
kosh DSPLaTeX % latex mylat
kosh DSPLaTeX % bibtex mydsp
kosh DSPLaTeX % latex mylat Odd x[n] = −x[−n] Imaginary X(ejω )
kosh DSPLaTeX % latex mylat
Real x[n] Even |X(ejω )| and odd arg X(ejω )
dvips ps2pdf (or equivalent) converts latex2pdf converts directly to pdf More informatoin
To view xdvi (DVI) ghostview (PS) or acroread (PDF) lp or lpr commands in Unix system. in
order to print them on paper.
5
http://www.miktex.org/, “MiKTeX is an up-to-date TeX implementation for the Windows operating
system”

T-61.246 DSP 2005 139/140 FORMULAS T-61.246 DSP 2005 140/140 FORMULAS

Fourier Series TÄNNE TULEE VIELÄ KAAVOJA.


Continuous-time signals Discrete-time sequences
∞ X
X x[n] = ck ejkωn
x(t) = ck ejkΩt
k=hN i
k=−∞
1
Z 1 X
−jkΩt ck = x[n]e−jkωn
ck = x(t)e N
T T n=hN i

Fourier Transform
Continuous-time signals Discrete-time sequences
Z ∞ Z
1 1
x(t) = X(jΩ)ejΩt dΩ x[n] = X(ejω )ejωn dω
2π −∞ 2π 2π
Z ∞ ∞
X
X(jΩ) = x(t)e−jΩt dt X(ejω ) = x[n]e−jωn
−∞
n=−∞

Connection to z-transform: z ↔ ejω .

Convolution
Continuous-time signals Discrete-time sequences

y(t) = h(t) ~ x(t) = x(t) ~ h(t) y[n] = h[n] ~ x[n] = x[n] ~ h[n]
Z ∞ ∞
X
= h(τ )x(t − τ )dτ = h[k]x[n − k]
−∞
k=−∞

Filter Design
s = k · (1 − z −1 )/(1 + z −1 ), k = 1 or k = 2/T
Ωprewarp,c = k · tan(ωc /2), k = 1 or k = 2/T
ωc = 2πfc /fs
(
1, |ω| < ωc sin(ωc n) ωc
H(ejω ) = ↔ h[n] = πn
= π
sinc( ωπc n )
0, |ω| ≥ ωc
hF IR [n] = hideal [n] · w[n]
1

HF IR (ejω ) = 2π −π
Hideal (ejθ )W (ej(ω−θ) )dθ

Multirate Systems
xu [n] = x[n/L], n = 0, ±L, ±2L, . . . ; xu [n] = 0, otherwise
xd [n] = x[nM ]
Xu (z) = X(z L )
1/M
PM −1
−k
Xd (z) = (1/M ) k=0 X(z WM )

PM −1 j(ω−2πk)/M
Xd (e ) = (1/M ) k=0 X(e )

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy