Вы находитесь на странице: 1из 44

Digital Signal Processing

Laboratory Guide
http://sp.utcluj.ro/html/Teaching.html
3rd Year AE
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 1 / 44
Outline
1
Laboratory 1 - Introduction to MATLAB
2
Laboratory 2 - Discrete-Time Signals
3
Laboratory 3 - Sampling of Analog Signals
4
Laboratory 4 - Discrete-Time Linear Time-Invariant Systems
5
Laboratory 5 - Linear and Circular Convolution
6
Laboratory 6 - Discrete Fourier Transform
7
Laboratory 7 - Finite Impulse Response Filters
8
Laboratory 8 - Discrete-Time Linear Time-Invariant Systems as Frequency
Selective Filters
9
Laboratory 9 - Innite Impulse Response Filters. Indirect Design Methods
10
Laboratory 10 - Innite Impulse Response Filters. Direct Design Methods
11
Laboratory 11 - Structures for the Realization of Finite Impulse Response
Systems
12
Laboratory 12 - Structures for the Realization of Innite Impulse Response
Systems
13
Laboratory 13 - Quantization of Digital Filter Coecients
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 2 / 44
Laboratory 1
L1. Introduction to MATLAB
Appendix A L. Grama, C. Rusu, Prelucrarea numerica a semnalelor - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: To be acquainted with MATLAB programming environment,
respectively with the main commands and functions that will be used in the
next laboratories, read Appendix A: Not iuni MATLAB (pp. 139-165) and enter
the described examples in the command line.
Exercises
1
Consider the matrices: A =
_
_
3 2 1
8 4 5
0 2 0
_
_
, B =
_
_
2 3 4
1 1 1
2 3 2
_
_
and the
scalar m = 4. Evaluate using MATLAB: C = A + B; D = A B; E = C + m;
F = A B; G = B m; H = A

; I = B

; J = A/B; K = A \ B; L = C
m
. Verify
if J = A B
1
and if K = A
1
B. Use the long e format.
2
Generate a linearly spaced vector between 3 and 9 with the increment 2.
3
Generate a 13 element linearly spaced vector between 3 and 9.
4
Generate a 9 point logarithmically spaced vector between decades 10
3
and
10
3
.
5
Evaluate the scalar product of: a =
_
1 2
_
and b =
_
3 3
_
.
6
y = 3:0.9:123 is the given vector. Find the length of the vector and generate
another vector of the same length, with only 1s elements.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 3 / 44
Laboratory 1
7
Evaluate the element by element product of the matrices: A =
_
_
9 8 7
6 5 4
3 2 1
_
_
and B =
_
_
1 0 1
1 0 1
1 0 1
_
_
.
8
Graph x(n) = sin
_
2
1
5
n
_
, n = 0, 10, using stem . The graph should be
represented by red stars; label the axes and write a title.
9
Generate a function named bplusa.m : function sumab = bplusa(a, b) in
order to evaluate the sum of two variables a and b .
10
Generate a function named bproducta.m :
function prodab = bproducta(a, b) in order to evaluate the product of two
vectors a and b .
11
Generate a function: function geometricmean = GeomMean(a, b) in order to
evaluate the geometric mean of two scalars a and b .
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 4 / 44
Laboratory 2
L2. Discrete-Time Signals
Chapter 1 L. Grama, C. Rusu, Prelucrarea numerica a semnalelor - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: In this laboratory the discrete time sequences (denition,
classication and properties) are presented. It will be also illustrated the way
to represent discrete-time signals using MATLAB. To be acquainted with
signals and sequences, read Chapter 1: Semnale si secvent e, paragraphs
1.1.1-1.1.2 (pp. 1-4), respectively paragraphs 1.2.1-1.2.2 (pp. 8-10) to see
the MATLAB functions used in the sequences description. Run scripts
1.3.1-1.3.12 (you can nd the MATLAB examples in Lab2 DSP Examples as:
L2 1, impulse, L2 3L2 4, UnitStep, L2 6L2 12).
Exercises
1
Generate and graph (using stem function) the sequence:
x(n) = {0, 1, 2, 1, 0, 1, 2, 1, 0}, n = 0, 8.
2
Generate the complex sequence: x(n) = (n) +ju(n), n = 0, 10, and graph the
real, respectively the imaginary part of the generated sequence, in the same
gure, using subplot(m, n, p) command.
3
Generate the ramp sequence, with initial value 0 and nal value 100, of length
20: x(n) =
100
19
n, n = 0, 19.
4
Graph the sequence: x(n) = 3 sin (4n) + 2 cos (0.72n), n = 0, 100. Is this
sequence periodic? If yes, which is the period?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 5 / 44
Laboratory 2
5
Plot the discrete sequence, of length 20: x(n) =
_
sin (0.2n), n > 10,
0, n 10.
6
Generate the complex sequence, of length 50:
x(n) = exp
_
0.1n + j
_
20.1n +

4
__
. Plot the sequence attenuated by sine,
respectively by cosine functions: x
1
(n) = exp (0.1n) sin
_
20.1n +

4
_
;
x
2
(n) = exp (0.1n) cos
_
20.1n +

4
_
.
7
Graph the attenuated sine sequence of length 100, given by:
x(n) =
_
sin (0.1n)
0.1n
, n = 0,
1, n = 0.
8
Generate and plot next sequences (abscissa n must include only the indicated
range):
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 6 / 44
Laboratory 2
x
1
(n) = 0.5(n), n = 5, 10; x
2
(n) = 0.8(n 5), n = 5, 1S0;
x
3
(n) = 1.5(n + 100), n = 150, 0; x
4
(n) = 2u(n), n = 20, 20;
x
5
(n) = 1.5u(n 10), n = 10, 20;
x
6
(n) = 2.5u(n + 10), n = 15, 15;
x
7
(n) = 1.2(n + 5) + 1.3 [u(n) u(n 20)] , n = 15, 25;
x
8
(n) = 2.2 sin
_
20.1n +

4
_
, n = 0, 49;
x
9
(n) = 1.5 sin
_

4
n +

3
_
, n = 0, 20;
x
10
(n) = 2 cos
_

5
n +

6
_
, n = 20, 20;
x
11
(n) = ln

sin
_

10
n
_
cos
_

10
n
_

, n = 20, 20;
x
12
(n) = exp (3n), n = 0, 9; x
13
(n) = (3)
n
sin
_

8
n
_
, n = 0, 20;
x
14
(n) = 10 sin
_
20.1n +

6
_
, n = 5, 20.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 7 / 44
Laboratory 2
9
Generate and plot next sequences:
x
1
(n) =
_
n(2 n), n = 5, 10
10, otherwise
10 n 20;
x
2
(n) =
_

_
8

i =0
a(n 2i );
_
a =
_
n + 3, n = 0, 5
0.5, otherwise
_
, n = 0, 10
50, otherwise
0 n 15;
10
Generate 3 sinusoidal sequences of dierent amplitude, frequency and phase
and plot them simultaneously on the screen (minimum 1 period).
11
Generate 16 periods of a periodic sequence; every period consists in 5 samples
of 1 and 10 samples of 0.
12
Generate an uniformly distributed random sequence, between 0 and 10. Plot
this sequence for n = 0, 49.
Hint: To generate an uniform distributed random sequence on a specied interval
[a, b], you have to multiply the output of rand function by (b a), and then to add
a. In the case of this example a = 0 and b = 10.
13
Generate a normally distributed random sequence (gaussian), between 0 and
10. Graph this sequence for n = 0, 49.
Hint: This sequence has a specic mean (5) and variance (5). To generate a gaussian
sequence with these parameters multiply the output of randn function by the
standard deviation (

5) and then add the desired mean (5).


Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 8 / 44
Laboratory 2
14
Generate and plot the sequences of length 100:
x
1
(n) = (n) (n 5); x
2
(n) = u(n 5);
x
3
(n) = n [u(n) u(n 10)] ; x
4
(n) = exp [(0.2 + j 0.3) n];
x
5
(n) = n [u(n) u(n 10)] + exp [(0.2 + j 0.3) n];
x
6
(n) = n [u(n) u(n 10)] + exp (0.3n) [u(n 10) u(n 20)] .
15
Add an uniformly distributed random sequence of mean 0 and maximum
amplitude 0.2, to the 100 length sequences, generated at exercise 14.
16
Repeat exercise 15, for a gaussian sequence of mean 0 and variance 0.1.
17
Plot using stem function, the sequence obtained by summing a sine sequence
by an uniform noise with the amplitude 10 times lower.
18
Generate and graph a rectangular sequence and a sawtooth one having 15
samples per period. You have to represent graphically 5 periods.
19
Generate 101 samples of a ramp sequence with the initial value 0 and the
increment equal by 0.01. Plot this sequence between 20 and 30.
Hint: For plotting this sequence you can use the syntax: stem(20:30, x(21:31))
assuming that the generated sequence was denoted by x .
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 9 / 44
Laboratory 2
20
Create a MATLAB function to generate a nite length sinusoidal sequence.
The function must have 5 input arguments: 3 for the sinusoids parameters
and 2 to specify the rst and the last index of the nite sequence. The
function will return a colon vector that will contain the sinusoid values.
Hint: function seq = gensin(ampl, freq, phase, ninitial, nnal) .
Use the created function in a MATLAB script to evaluate the minimum, the
maximum, the mean and the standard deviation of a sinusoidal sequence with
parameters: ampl = 1.5 , freq = 1/15 , phase = pi/6 , n = 0, 50.
21
Modify the function generated at 20, to return 2 output arguments: a vector
that contains the sequences values and a vector with the sequences indices.
Hint: function [seq, n] = gensin1(ampl, freq, phase, ninitial, nnal) .
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 10 / 44
Laboratory 3
L3. Sampling of Analog Signals
Chapter 1 L. Grama, C. Rusu, Prelucrarea numerica a semnalelor - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: The aim of this laboratory is the introduction of analog signals,
the way to obtain a discrete-time sequence from an analog signal (sampling
of analog signals) and the way to reconstruct analog signals from samples.
To be acquainted with analog signals, their way of sampling and their
reconstruction from samples see Chapter 1: Semnale si secvent e, paragraphs
1.1.1-1.1.5 (pp. 1-8). In paragraph 1.2.3 (p. 11) the MATLAB functions
used for interpolation are presented. Run scripts 1.3.13-1.3.15 (you can nd
the MATLAB examples in Lab3 DSP Examples as: L3 1L3 3). Study the
problem 1.3.16.
Exercises
1
Plot an amplitude modulated signal, sampled by 1MHz, whose carrier is of
100kHz and modulation signal of 10kHz, for a modulation index m = 1.2.
Graph on the same gure, but in a dierent pane the suppressed carrier
amplitude modulated sequence.
2
From all sequences obtained after sampling analog sinusoidal signals by 50kHz,
which one has the major variation?
3
Generate 101 samples of a sequence obtained from an analog sinusoidal signal
sampled by 1kHz; the analog sinusoid has unitary amplitude, zero phase and a
frequency of 100Hz.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 11 / 44
Laboratory 3
From the previous sequence generate a full-wave rectied one ( abs );
Perform the arithmetic mean of the previously obtained sequences;
Graph the three sequences in the same gure, but in dierent panes.
4
Consider an analog sinusoidal signal with frequency F = 200Hz. This signal is
sampled by F
s
= 800Hz. Plot the analog signal, the discrete-time sequence
obtained after sampling and the analog signal that can be recovered from
samples (F
sim
= 8kHz).
5
Consider the analog sinusoids with frequencies: 300Hz, 400Hz, 500Hz, 700Hz,
900Hz. All of them are sampled by 900Hz (dont forget the simulation
frequency). Plot the analog sinusoidal signals, the sequences obtained after
sampling, the analog signals that can be recovered from the corresponding
samples and also the corresponding spectra. Is there any alias error? Why?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 12 / 44
Laboratory 4
L4. Discrete-Time Linear Time-Invariant Systems
Chapter 2 L. Grama, C. Rusu, Prelucrarea numerica a semnalelor - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: The aim of this laboratory is to present discrete-time LTIS. The
way to evaluate the system response to arbitrary input signals, with zero
initial conditions, is illustrated. In this laboratory, the usage of z-transform to
LTIS characterization is also presented. To be familiar with LTIS read Chapter
2: Semnale discrete, paragraphs 2.1, 2.1.1-2.1.3 (pp. 43-46). The MATLAB
functions used to evaluate the output, the impulse response of a LTIS,
respectively the functions used to characterize the discrete-time systems are
described in paragraphs 2.2.1-2.2.2 (pp. 48-50). Run scripts 2.3.1-2.3.9 (you
can nd the MATLAB examples in Lab4 DSP Examples as: L4 1L4 9). Study
problems 2.3.102.3.13.
Exercises
1
Demonstrate through a MATLAB scrip (as L4 1.m) that the system
H{x(n)} = x
2
(n) is nonlinear. Consider: x
1
(n) = sin (20.1n),
x
2
(n) = sin (20.15n), a = 3, b = 3.
2
A discrete LTIS is characterized by the constant-coecient dierence equation:
y(n) 1.5 cos

8
y(n 1) + 0.95y(n 2) = x(n) + 0.4x(n 1).
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 13 / 44
Laboratory 4
Determine the poles of the systems transfer function, which are the roots of
the polynomial A(z) = 1 +
N

k=1
a
k
z
k
using the roots command. If these roots
are complex-conjugate, the response of the system contains harmonic
components. Represent the real and the imaginary part of the complex
sequences p
n
k
u(n), for n = 0, 30, where p
k
are the systems poles;
Accordingly to the dierence equation, the impulse response sequence is:
h(n) = (a
1
p
n
1
+ a
2
p
n
2
) u(n). Determine the constants a
1
and a
2
. Evaluate the
impulse response using the MATLAB command impz (see L4 8.m);
Determine the steady-state response of the system to the complex exponential
input sequence (see L4 9.m): x(n) = e
j
0
n
, for n = 0, 60,
0
=

6
, using the
relation:
y(n) = |H (
0
)| e
j
0
n+H(
0
)
.
3
Analyze the eect of poles and zeros of a system function H(z) on the
magnitude of the frequency response function |H()|, for the systems:
H
1
(z) =

1 z
1
z
1

1 z
2
z
1

where:
1) z
1,2
= 1; 3) z
1,2
= e
j

3
; 5) z
1,2
= e
j
2
3
; 7) z
1,2
= 1;
2) z
1,2
= e
j

6
; 4) z
1,2
= e
j

2
; 6) z
1,2
= e
j
5
6
;
Analyze how |H()| is modifying accordingly to the zeros position, and
represent the zeros in z-plane. What do you observe? Comment on the results.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 14 / 44
Laboratory 4
H
2
(z) =
0.3

1 p
1
z
1

1 p
2
z
1
where:
1) p
1,2
= 0.3; 2) p
1,2
= e
j

4
; 3) p
1,2
= e
j

2
; 4) p
1,2
= 0.3;
Analyze how |H()| is modifying accordingly to the poles position, and
represent the poles in z-plane. What do you observe? Comment on the results.
4
Find the impulse response of the system described by the transfer function:
H(z) =
1 + z
1
+ z
2
+ z
3
1 0.5z
1
4z
2
+ 2z
3
.
5
Evaluate the rst 50 samples of the impulse response sequence of the system:
H(z) =
z
2
+ 1
z
3
1.9z
2
+ 1.55z 0.425
.
6
Evaluate the rst 100 samples of the impulse response of the system:
H(z) =
z
z 1
.
7
Next transfer functions of some discrete LTIS are considered:
H
1
(z) = 1 4z
1
+ 4z
2
; H
4
(z) =
_
1 + z
1
_
2
1 z
1
+ 0.25z
2
;
H
2
(z) = 1 + 4z
1
+ 4z
2
; H
5
(z) =
_
1 z
1
_
2
1 z
1
+ 0.25z
2
;
H
3
(z) = 1 z
1
+ 0.25z
2
; H
6
(z) =
1
1 z
1
+ 0.25z
2
;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 15 / 44
Laboratory 4
Using the zplane command represent the pole-zero diagrams for the system
functions H
i
(z), i = 1, 6;
Using the freqz command represent the frequency response characteristics for
each system. Specify what type of system is described by each transfer function;
Evaluate and plot the unit impulse and the unit step response for H
5
(z).
8
Find the impulse response of the system: H(z) =
0.5z
2
+ 0.5z
z
2
z 0.5
.
9
A LTIS is characterized by the system function:
H(z) =
(z + 0.2)
_
z
2
+ 5
_
(z 0.7) (z
2
z + 0.49)
.
Represent the poles and the zeros in the z-plane;
Evaluate and plot the phase response characteristic. Is this system a
linear-phase one?
10
Two causal systems are considered. Determine which one is stable. Comment
on your answer.
H
1
(z) =
1 0.6z
1
+ 1.15z
2
0.98z
3
+ 0.98z
4
1 + 1.27z
1
+ 2.02z
2
+ 1.54z
3
+ 0.98z
4
;
H
2
(z) =
2 2.54z
1
+ 5z
2
4.3z
3
+ 3.27z
4
1 0.77z
1
+ 0.82z
2
+ 0.41z
3
+ 0.51z
4
.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 16 / 44
Laboratory 4
11
For the sequence:
x(n) = (0.9)
n
sin (0.2n), n = 0, 99,
nd the impulse response after you evaluate X(z).
Hint: The z-transform of the sequence
x(n) = a
n
sin (
0
n)u(n)
is
H(z) =
az
1
sin
0
1 2az
1
cos
0
+ a
2
z
2
, |z| > |a|.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 17 / 44
Laboratory 5
L5. Linear and Circular Convolution
Chapters 2 and 3 L. Grama, C. Rusu, Prelucrarea numerica a semnalelor - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: The aim of this laboratory is to present the linear and the
circular convolution. You can nd the theoretical aspects regarding the linear
convolution in Chapter 2: Semnale discrete, paragraph 2.1.4 (pp. 47-48),
respectively in 2.2.3 (p. 50) the MATLAB commands used for linear
convolution evaluation. In Chapter 3: Transformata Fourier discreta, paragraph
3.1.3 (pp. 95-96) you can nd the aspects regarding the circular convolution.
The MATLAB functions used are presented in 3.2.2 (p. 99). Run scripts
2.3.14, respectively 3.3.6-3.3.8, 3.3.11 (you can nd the MATLAB examples in
Lab5 DSP Examples as: L5 1L5 5). Study problems 2.3.152.3.16.
Exercises
1
Determine the linear convolution of the sequences: x
1
(n) = |10 n| and
x
2
(n) = 1.5 cos
_
20.1n +

4
_
, for n = 0, 20. Plot the two sequences and the
sequence obtained after convolution. Which is the fundamental period of the
linear convolution?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 18 / 44
Laboratory 5
2
The impulse response of a LTIS is:
h(n) =
_
exp (0.1n), n = 0, 31,
0, otherwise.
At the input of the system the sequence x(n) = u(n) u(n 20) is applied
(u(n) is the unit step sequence). Determine the system output using the linear
convolution.
3
The impulse response of a LTIS is:
h(n) =
_
exp (0.15n), n = 0, 31,
0, otherwise.
At the input of the system the sequence x(n) = u(n) u(n 30) is applied
(u(n) is the unit step sequence). Determine the system output using the linear
convolution.
4
Consider the system described by the z-domain transfer function:
H(z) =
z 1
(z 0.25)(z 0.5)
.
Determine the rst 100 samples of the unit step response sequence;
Express the system function as: H(z) = H
1
(z) + H
2
(z);
Determine the unit step response of the individual blocks and then add the
results. Compare the obtained result with the one obtained in the rst part.
5
Consider the system: H(z) =
z
z 0.5
. Evaluate:
The unit step response;
The unit ramp response;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 19 / 44
Laboratory 5
The response to the sequence: x(n) = 10 cos
n
3
u(n);
The response to the sequence: x(n) = 10 0.5
n
u(n).
6
Two linear systems are connected in cascade:
h
1
(n) = { 2

, 3, 2, 1, 0.5, 1, 2, 4},
h
2
(n) = { 3

, 1, 5, 0, 2, 6}.
Generate an arbitrary input sequence x(n) (i.e., a sinusoidal sequence);
Evaluate the output sequence of the rst system, using the linear convolution,
and then evaluate the output sequence of the cascade formed by the two
systems;
If the cascade order is changed, repeat the operations involved in the precedent
part. What can you conclude?
Suppose that the second system is characterized by the input-output relation:
y(n) = 0.01 [x(n)]
2
, and the rst system remains unchanged. Repeat the
precedent parts and compare the output resultant sequences.
7
Evaluate the circular convolution of the sequences: x
1
(n) = (2)
n
and
x
2
(n) = 1.1 cos
_
0.25n +

6
_
, for n = 0, 10. Plot the two sequences and the
sequence obtained after the evaluation of the circular convolution. Which is
the fundamental period of the circular convolution?
8
Consider the sequences: x
1
(n) = 1.1 sin
_
20.05n +

4
_
and x
2
(n) = (1)
n
,
for n = 0, 15. Write a MATLAB script to evaluate:
The linear convolution;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 20 / 44
Laboratory 5
The 16-point circular convolution in two ways (using circonv and, respectively
t );
The circular convolution in minimum number of points required in order to
obtain the same result as in the case of the linear convolution, in two ways
(using circonv and, respectively t ).
9
Evaluate the linear and the circular (using minimum length DFT required)
convolution of the sequences: x
1
(n) = u(n) u(n 20) (n = 0, 30) and
x
2
(n) = (0.7)
n
(n = 0, 20). Which is the minimum length for the period N
such that the values of the two convolutions to be the same? Graph the two
sequences and also those obtained after the evaluation of linear, respectively
circular convolution.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 21 / 44
Laboratory 6
L6. Discrete Fourier Transform
Chapter 3 L. Grama, C. Rusu, Prelucrarea numerica a semnalelor - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: The aim of this laboratory is to present the Discrete Fourier
Transform (DFT): its denition, its properties and also its implementation in
MATLAB. To become familiar with DFT read Chapter 3: Transformata Fourier
discreta, paragraphs 3.1.1-3.1.2 (pp. 90-95), respectively paragraph 3.1.4 for
the sampling in the frequency domain (pp. 96-97). The MATLAB functions
used to implement the DFT are presented in 3.2.1 (pp. 98-99). Run scripts
3.3.13.3.5, 3.3.93.3.10, 3.3.12 (you can nd the MATLAB examples in
Lab6 DSP Examples as: L6 1L6 8). Study problems 3.3.133.3.16.
Exercises
1
Plot the magnitude and the phase of the corresponding DFT for:
x(n) =
_
1, n = 0, 5,
0, n = 6, 10.
2
Consider the sequence given in exercise 1; pad it by 116 zeros. Plot the
magnitude and the phase of the DFT for the zero-padded sequence.
3
Generate a MATLAB program to verify the Parseval relationship for:
x(n) =
_
n + 2j , n = 0, 63,
0, otherwise.
y(n) =
_
n + 3j , n = 0, 63,
0, otherwise.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 22 / 44
Laboratory 6
4
An amplitude modulated signal, sampled by 1MHz, whose carrier is of 100kHz
and modulation signal of 10kHz is considered. For a modulation index of
m = 0.7 graph the magnitude and the phase spectra.
5
Consider the sequences: x
1
(n) = 0.2 sin
_
20.1n +

8
_
, x
2
(n) = 2e
0.2n
,
n = 0, 49. Plot the considered sequences and their product. Evaluate the
magnitude and the phase spectra of the DFTs for x
1
(n), x
2
(n) and x
1
(n)x
2
(n).
Plot the results.
6
Evaluate the N-point DFTs of: x
1
(n) = u(n) u(n 20) (n = 0, 30),
x
2
(n) =
_
n 1, n = 0, 5,
(1)
n
, n = 6, 10.
Graph the sequences and their DFTs (real
and imaginary parts, magnitude and phase) for [, ] and
N = 32; 128; 256; 512; 1024.
7
Consider the sequences: x
1
(n) = { 3

, 4.2, 11, 0, 7, 1, 0, 2},


x
2
(n) = { 1.2

, 3, 0, 0.5, 2},
Evaluate the linear convolution (using conv ) between x
1
(n) and x
2
(n). Which
is the length of the result?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 23 / 44
Laboratory 6
In some cases, it should be convenient to evaluate the linear convolution using
the Fourier transform. At the beginning, evaluate the linear convolution in a
some way inconsistent manner. Extend x
2
(n) with three zeros, so that both
sequences to have the same length. Evaluate then the 8-point DFT for the two
sequences. After multiplying the two DFTs, evaluate the IDFT of the product
X
1
(k)X
1
(k). Take into account only the real part of the result, imaginary part
being the result of the roundo errors. In what measure the result is identical
with the one obtained through the linear convolution. How many samples are
accurate? Why?
Which is the minimum length DTF that must be used, so that through the
preceding procedure to obtain the same result as in the case of linear
convolution? Pad both sequences by zeros, till both of them are of length equal
by the minimum required to evaluate accurate the linear convolution using the
DFT. Repeat the previous part.
Pad with ve zeros the two sequences, so that their length is greater than the
minimum required. Repeat the previous part and specify to what extent a
greater number of samples aect the result.
8
Consider the sequence: x(n) = { 3

, 2, 7, 1, 4}.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 24 / 44
Laboratory 6
Evaluate the 5-point DFT for the sequence x(n). Multiply the DFT by a
complex exponential: e
j
2k
5
. Compute the IDFT of the product, that is to nd
the sequence x
1
(n): x
1
(n) = IDFT{X(k)e
j
2k
5
}. Take into account only the
real part of the sequence x
1
(n), the imaginary part being the result of the
roundo errors. Compare x
1
(n) by x(n). Are these sequences obtained by
circular translation?
Repeat the previous part to obtain a circular shift by 3 samples.
How can you modify this technique so that to be possible to evaluate the linear
convolution?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 25 / 44
Laboratory 7
L7. Finite Impulse Response Filters
Chapter 2 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: The subject of this laboratory are FIR lters. In the rst part
some theoretical aspects regarding the digital lters are presented, their
advantages and disadvantages toward the analog ones. The FIR lters
characteristics are illustrated and some design methods are described:
windowing method, sampling in the frequency domain method and the
optimal method. To be acquainted with the digital lters read Chapter 2:
Filtre cu raspuns nit la impuls, paragraphs 2.1-2.1.1 (pp. 41-42), respectively
2.1.2-2.1.3 (pp. 42-48) to become familiar with the FIR lters (their
characteristics and approximation methods). The MATLAB functions used to
implement FIR lters are presented in 2.2.1-2.2.4 (pp. 48-54). Run scripts
2.3.12.3.4 (you can nd the MATLAB examples in Lab7 DSP Examples as:
L7 1L7 4). Study problems 2.3.52.3.6.
Exercises
1
Design a 21 FIR LPF, with the cuto frequency of 0.2.
2
Redesign the previous lter for a larger transition band.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 26 / 44
Laboratory 7
3
Graph the rectangular, triangular, Blackman, Hamming, Hanning, Kaiser
(dierent ) windows, and also their magnitude frequency response
characteristics. Note the principal lobes values and the maximum amplitudes
of the secondary lobes [dB]. Verify the results by those given in Table 2.3. For
N = 20 study demowindows.m . What happens if you modify the windows
length (N = 50)? What can you say about the windows eect in the FIR
lters design?
4
Design a FIR band-reject lter, of order 21, using the windowing method (use
the windows generated in exercise 3), with the stop band limits F
s1
= 10kHz,
F
s2
= 15kHz. The sampling frequency considered is F
s
= 90kHz. Plot the
frequency response characteristic, the zeros distribution and the impulse
response of the lter, for each window.
5
Design a FIR LPF, of order 36, using the sampling in the frequency domain
method, with the pass band limit F
p
= 15kHz and the sampling frequency
F
s
= 50kHz. Sketch the frequency response characteristics of the lter, the
zeros distribution and the impulse response.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 27 / 44
Laboratory 7
6
Design a FIR BPF, of minimum order, with the frequencies F
s1
= 10kHz,
F
p1
= 12kHz, F
p2
= 60kHz, F
s2
= 62kHz and the sampling frequency
F
s
= 130kHz, the minimum attenuation in the stop bands of 40dB and the
maximum attenuation in the pass band of 3dB. Sketch the frequency response
characteristics of the lter.
Hint: In order to evaluate the pass and stop band deviations use:
A
PB
= 20 lg
1 +
p
1
p

p
=
10
A
PB
20
1
10
A
PB
20
+ 1
A
SB
= 20 lg
s

s
= 10

A
SB
20
.
7
Redesign the FIR PBF from exercise 6, using the SPTool graphical interface.
8
Consider the FIR lter described by the input-output relationship:
y(n) =
1
4
[x(n) + x(n 1) + x(n 2) + x(n 3)]. Evaluate and sketch the
impulse response and the frequency response characteristics.
9
Design a 33 order Hilbert transformer, with optimum response, such that the
normalized frequency to be within 0.05 and 0.45.
10
Design a 55 linear phase FIR LPF, with the transition frequencies 0.2 and 0.3.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 28 / 44
Laboratory 7
11
Design a FIR lter that approximate the magnitude characteristic:
|H()| =
_
_
_
0, 0 < < 0.2,
1, 0.25 < < 0.45
0, 0.5 < < .
Evaluate and sketch the impulse response and the frequency response
characteristics.
12
Design a linear phase LPF, of order 51, to approximate the characteristic of an
ideal LPF. The cuto frequency is considered to be 0.2. Graph the frequency
response characteristics for the designed lter. You should observe the
presence of the Gibbs phenomenon.
13
Design a linear phase BPF, of order 40, to approximate the characteristic of an
ideal BPF (rectangular window) with the cuto frequencies: 0.2 and 0.6.
14
Repeat exercise 13 for a Hamming window. Why the Gibbs phenomenon
doesnt appear anymore? What can you say about the transition band?
15
Design a lter to approximate the characteristic of a dierentiator,
H() = /, considering a Blackman window. The order of the lter should
be 40.
16
Consider the moving average lter described by the constant-coecient
dierence equation: y(n) =
1
3
[x(n) + x(n 1) + x(n 2)].
Evaluate and plot the magnitude and the log-magnitude frequency response for
this lter;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 29 / 44
Laboratory 7
At the input of this lter a signal mixed up with noise is applied. What do you
obtain at the output? Comment on the result;
Repeat the previous parts for a ve order moving average lter, described by the
dierence equation:
y(n) =
1
5
[x(n) + x(n 1) + x(n 2) + x(n 3) + x(n 4)].
17
Using a rectangular window, design a FIR BPF, of order 55, with the
normalized cuto frequencies 0.18 and 0.33. Plot the impulse response and
the frequency response characteristics.
18
Design a 55 order FIR lter, of equal ripple, to approximate the frequency
response:
H() =
_
_
_
0, 0 < < 0.2,
1, 0.22 < < 0.43
0, 0.5 < < .
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 30 / 44
Laboratory 8
L8. Discrete-Time Linear Time-Invariant Systems as Frequency Selective
Filters
Chapter 1 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To de done: The aim of this laboratory is to present the LTIS as selective
lters in the frequency domain. In the rs part the ideal lters characteristics
are illustrated, and then some particular classes of selective lters are shown:
digital resonators, comb lters, notch lters, all-pass lters and digital
sinusoidal oscillators. The theoretical aspects are illustrated in Chapter 1:
Filtrari selective paragraph 1.1 (pp. 1-20), respectively in paragraph 1.2 (p.
20) the MATLAB functions are described. Run scripts 1.3.11.3.9 (you can
nd the MATLAB examples in Lab8 DSP Examples as: L8 1L8 9).
Exercises
1
Redo example L8 9, for the other values of the frequency f
0
.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 31 / 44
Laboratory 9
L9. Innite Impulse Response Filters. Indirect Design Methods
Chapter 3 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: This laboratory is focused on designing, analyzing and
implementing IIR lters. In some applications, the IIR lters are more
advantageously than the FIR lters because they can realize excellent
selectivity characteristics with a lower order of the transfer function. In
contrast with the FIR lters, the IIR ones cannot have linear phase. To
become familiar with the IIR lters read Chapter 3: Filtre cu raspuns innit la
impuls, paragraphs 3.1, 3.1.1 (pp. 70-77), respectively paragraph 3.1.3 (pp.
83-84) about the IIR lters advantages. The MATLAB functions used to
implement the IIR lters are presented in 3.2.1-3.2.3 (pp. 84-88). Run scripts
3.3.13.3.4 (you can nd the MATLAB examples in Lab9 DSP Examples as:
L9 1L9 4). Study problems 3.3.53.3.6.
Exercises
1
Using the impulse invariance method design a digital Butterworth band-pass
lter, for which:
The attenuation is lower than 1dB at 4kHz and 6kHz;
The attenuation is greater than 40dB at 3kHz and 8kHz;
The sampling frequency is 20kHz.
1 Evaluate and sketch the frequency response characteristics for the analog BPF
and for the corresponding digital one.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 32 / 44
Laboratory 9
2 Evaluate and sketch the impulse response of the digital BPF and the pole-zero
diagram in the z-plane.
3 Is the obtained digital lter stable?
Repeat the problem using the bilinear transformation method.
2
Repeat exercise 1 for a Cebsev I lter. Comment on the dierences.
3
Repeat exercise 1 for a Cebsev II lter. Comment on the dierences.
4
Repeat exercise 1 for an Elliptic lter. Comment on the dierences.
5
Repeat exercises 14 and design these lters using the graphical interface
SPTool.
6
Consider the analog lter described by the system function:
H(s) =
2
s + 2
s
2
+ 2
2s
2
+ 3s + 2
. Using the bilinear transformation method, obtain
the corresponding digital lter; the sampling period is equal by T = 0.8. What
kind of lter is the obtained one? Is this lter stable?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 33 / 44
Laboratory 10
L10. Innite Impulse Response Filters. Direct Design Methods
Chapter 2 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: In this laboratory the direct design methods for IIR lters are
described. The theoretical aspects regarding the direct design methods for IIR
lters are presented in Chapter 3: Filtre cu raspuns innit la impuls in paragraph
3.1.2 (pp. 78-83), respectively in 3.2.4 (pp. 88-91) the MATLAB functions
are illustrated. Run scripts 3.3.73.3.11 (you can nd the MATLAB examples
in Lab10 DSP Examples as: L10 1L10 5). Study problems 3.3.123.3.13.
Exercises
1
Consider a Cebsev II digital HPF, with 4 poles and 4 zeros, with the system
function: H
d
(z)
=
0.076945 0.19009z
1
+ 0.25374z
2
0.19009z
3
+ 0.076945z
4
1 + 0.80034z
1
+ 0.73056z
2
+ 0.17774z
3
+ 0.035329z
4
Using the Pade approximation method for H
d
(z), and considering the impulse
response length equal by 50, compare the methods performances for:
M = {2; 5; 7} and N = {2; 5; 7}.
2
Consider the lter given in exercise 1; approximate it using the least squares
design method.
3
Consider the lter given in exercise 1; approximate it using Pronys design
method.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 34 / 44
Laboratory 10
4
Consider the lter given in exercise 1; approximate it using Shanks design
method.
5
Using Yule-Walker method, synthesize a BRF, with the stop band between 0.3
and 0.6 and the cuto pass band frequencies 0.25 and 0.65.
6
Design a 5 order Butterworth LPF, which satises the condition:
0.9 < H() < 1, for 0 < f < 0.2.
7
Consider a LTIS described by the transfer function:
H(z) =
0.05634(1 + z
1
)(1 1.01666z
1
+ z
2
)
(1 0.68z
1
)(1 1.4461z
1
+ 0.7957z
2
)
. Sketch the pole-zero
diagram, the frequency response characteristics and the group delay
characteristic.
8
Design a minimum order Butterworth LPF, which satises the conditions:
0.99 < |H(f )| < 1 for 0 < f < 0.22 and 0 < |H(f )| < 0.01 for 0.25 < f < 0.5.
Plot the frequency response characteristics and the group delay characteristic;
Find the poles and the zeros of the system function and write the system
function expression in a compact manner.
9
Repeat exercise 8 for a Cebsev lter.
10
Design a Cebsev BRF which must reject the frequency f = 0.22. The design
must satisfy the next requirements:
The order of the lter is ten;
The stop band width is 0.04;
The widths of the transition bands are 0.03;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 35 / 44
Laboratory 10
The stop band attenuation must be at least 20dB, and the ripple in the pass
band is 1dB.
Evaluate the output of this lter to the excitation x(n) = sin (20.22n), for
n = 0, 299. Comment on the result.
11
A LTIS is described by the transfer function: H(z) =
z
z 0.9
.
Evaluate and sketch the impulse response;
Evaluate and sketch the frequency response characteristics (the magnitude and
the phase);
Evaluate the output of this lter to the excitation x(n) = sin 20.05n, for
n = 0, 499. Compare the excitation with the output sequence. How are aected
the amplitude and the phase of the input sinusoid?
Repeat the previous part for x(n) = sin (20.1n), for n = 0, 499.
12
Two continuous-time signals are considered, x
a
(t) and y
a
(t), which are in an
integral relationship: y
a
(t) =
_
t
0
x
a
(t)dt. The integral can be approximated
using the trapezoidal rule as follows: y
a
(t) y
a
(t
0
) +
t t
0
2
[x
a
(t) + x
a
(t
0
)].
A discrete integrator can be represented by the nite dierence equation:
y(n) = y(n 1) +
T
2
[x(n) + x(n 1)], where x(n) and, respectively y(n)
represent the sampled signals derived from x
a
(t) and y
a
(t).
Determine the transfer function H(z) of the discrete integrator;
Generate two vectors to describe the discrete integrator. Chose T = 0.1s;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 36 / 44
Laboratory 10
Consider the signal: x
a
(t) = 0.9
t
sin (2t). Its integral can be approximated by
discrete integrator. For this purpose, this signal is sampled by T = 0.1s and it
is passed through the integrator. Evaluate the rst 100 samples for the output
sequence and compare them by the theoretical result;
Repeat previous parts for T = 0.05s.
13
Consider the LTIS described by the system function: H(z) =
1
1 z
N
.
Create a variable to describe this system, and then generate 100 samples of the
systems impulse response (N = 10);
Evaluate and sketch the frequency response characteristics (the magnitude and
the phase);
Generate 10 samples of the sequence: x(n) = 9 n, for n = 0, 9. Pad x(n) by
90 zeros. Pass this new sequence through the lter and evaluate the rst 100
samples of the response sequence.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 37 / 44
Laboratory 11
L11. Structures for the Realization of Finite Impulse Response Systems
Chapter 2 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: This laboratory is dedicated to the realization of discrete-time
LTIS with nite impulse response. The direct form, the cascade structure,
and the lattice one will be presented. It is also described the frequency
sampling implementation for a FIR system its advantage consists in the
computational eciency toward other implementations. The theoretical
aspects regarding discrete-time LTIS implementation are presented in Chapter
4: Structuri pentru implementarea sistemelor discrete paragraph 4.1 (pp.
122-123), respectively in 4.1.1. (pp. 123-132) the structures for the
realization of FIR systems are described. Study problems described in the
examples 4.3.1-4.3.3 (you can nd the MATLAB scripts in Lab11 DSP Examples
as: L11 1L11 4).
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 38 / 44
Laboratory 11
Exercises
1
Next FIR systems are considered:
H
1
(z) = 1
5
6
z
1
+
1
6
z
2
;
H
2
(z) =
_
1 2z
1
__
1 0.8e
j

6
z
1
__
1 0.8e
j

6
z
1
_
;
H
3
(z) = 1 1.27z
1
+ 1.19z
2
+ 1.18z
3
+ 0.4z
4
;
H
4
(z) = 0.5 + 0.2z
1
0.3z
2
+ z
3
;
Synthesize and draw the structures corresponding to the direct form, cascade
and respectively lattice implementations.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 39 / 44
Laboratory 12
L12. Structures for the Realization of Innite Impulse Response Systems
Chapter 2 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: In this laboratory the direct, the cascade, the parallel and the
lattice structures for the IIR systems are presented. To be acquainted with
the theoretical aspects regarding discrete-time IIR systems implementation
structures read Chapter 4: Structuri pentru implementarea sistemelor discrete, the
paragraph 4.1.2 (pp. 132-141), respectively the paragraph 4.2 (pp. 141-143),
where the used MATLAB functions for IIR systems implementation are
presented. Run script 4.3.8 (you can nd the MATLAB example in
Lab12 DSP Examples as: L12 1). Study problems 4.3.44.3.7.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 40 / 44
Laboratory 12
Exercises
1
Next IIR systems are considered:
H
1
(z) =
3
_
1 z
1
_
_
1 +

2z
1
+ z
2
_
(1 + 0.3z
1
) (1 0.7z
1
+ 0.49z
2
)
;
H
2
(z) =
_
1 0.3e
j

4
z
1
__
1 0.3e
j

4
z
1
_
_
1 0.6e
j

6
z
1
_ _
1 0.6e
j

6
z
1
_ ;
H
3
(z) =
3
1 1.27z
1
+ 1.19z
2
+ 1.18z
3
+ 0.4z
4
;
H
4
(z) =
0.5 + 0.2z
1
0.3z
2
+ z
3
1 0.3z
1
+ 0.2z
2
+ 0.5z
3
;
Synthesize and draw the structures corresponding to the direct forms I and II,
cascade, parallel and respectively lattice implementations. Specify for each
system if it is stable or not.
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 41 / 44
Laboratory 13
L13. Quantization of Digital Filter Coecients
Chapter 2 L. Grama, A. Grama, C. Rusu, Filtre numerice - aplicat ii si probleme, Ed. UTPRES, 2008
To be done: The aim of this laboratory is the analysis of the word-length
eects in representing numerical values on systems performances, in dierent
structures. Finite-word-length eects report on quantization consequences
that are present in the digital implementations of systems, either in hardware
or in software. We want to analyze the round-o quantization eects to
digital lters. Theoretical aspects regarding quantization of digital lters
coecients are illustrated in Chapter 5: Cuantizarea coecient ilor ltrelor
digitale, paragraphs 5.1, 5.1.1-5.1.3 (pp. 169-174). The round-o
quantization eects in digital lters are illustrated in the paragraph 5.1.4 (pp.
174-184). The MATLAB functions used in this laboratory are described in
the paragraph 5.2 (pg. 185-187). Run scripts 5.3.15.3.13 (you can nd the
MATLAB examples in Lab13 DSP Examples as: L13 1L13 13).
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 42 / 44
Laboratory 13
Exercises
1
Next IIR systems are considered:
H
1
(z) =
1 2 cos
2
6
z
1
+ z
2
1 1.4 cos
2
6
z
1
+ 0.49z
2

1 2 cos
2
4
z
1
+ z
2
1 1.2 cos
2
4
z
1
+ 0.36z
2
;
H
2
(z) =
0.5 + 0.2z
1
0.3z
2
+ 0.1z
3
+ z
4
1 + 0.1z
1
0.3z
2
+ 0.2z
3
+ 0.5z
4
;
Determine the numerators and denominators coecients and sketch the
pole-zero diagram and the frequency response characteristics;
For the direct form quantize (using truncation) the transfer function coecients
on 15, 8 and 4 bits. Note the values obtained for each case;
1. Sketch the pole-zero diagram and the frequency response characteristics for
the transfer functions with quantized coecients;
2. Compare the frequency response characteristics of the lters with
unquantized coecients with those with quantized coecients. How many bits
are necessarily for the coecients representation such that this limitation do
not aect much the magnitude characteristic?
Determine the parallel form of the given transfer functions;
1. Quantize the coecients of each function from the structure on 15, 8 and 4
bits. Note the values obtained for each case;
2. Evaluate the global transfer function summing all the transfer functions with
quantized coecients and plot the global frequency response and compare the
results with the one previously obtained;
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 43 / 44
Laboratory 13
Determine the cascade form of the given transfer functions;
1. Quantize the coecients of each function from the structure on 15, 8 and 4
bits. Note the values obtained for each case;
2. Evaluate the global transfer function multiplying all the transfer functions
with quantized coecients;
3. Sketch the pole-zero diagram and the global frequency response and
compare the results with the one obtained for the direct form;
Determine the lattice structure of the given transfer functions;
1. Quantize the coecients of each function from the structure on 15, 8 and 4
bits. Note the values obtained for each case;
2. Evaluate the global transfer function and plot the pole-zero diagram and the
global frequency response; compare the results with the one previously obtained.
2
Redo example L13 12, for L

and L
1
norms. What can you notice?
3
Redo example L13 13, for L

and L
2
norms. What can you notice?
Laboratory Guide (sp.utcluj.ro) Digital Signal Processing 3rd Year AE 44 / 44