Laboratory 2: Convolution and Discrete Functions
Laboratory 2: Convolution and Discrete Functions
Aims
The emphasis in this lab session is on the representations and implementation of convolution using
MATLAB. Furthermore, tools to solve a constant coefficient linear difference equation available in
MATLAB will also be explored.
Pre-Lab:
Discrete-time Systems and Convolution
Mathematically, a discrete-time system (or discrete system for short) is described as an operator H[.]
that takes a sequence x(n) (called excitation) and transforms it into another sequence y(n) (called
response). That is,
𝑦(𝑛) = Ƕ[𝑥(𝑛)]
In DSP we will say that the system processes an input signal into an output signal. Discrete systems are
broadly classified into linear and nonlinear systems. We will deal mostly with linear systems. A discrete
system H[.] is a linear system if and only if it satisfies the principle of superposition. Furthermore, a
linear system in which an input-output pair, x(n) and y(n), is invariant to a shift k in time is called a linear
time-invariant (LTI) system.
An LTI system is completely characterized in the time domain by the impulse response h(n). Thus,
response of such a system to an arbitrary input x(n) is given by a linear convolution sum:
>> y = conv(x,h);
Page 1
Laboratory 2: Convolution and Discrete Functions 2.2
to obtain the correct y(n) values. However, the conv function neither provides nor accept any timing
information if the sequences have arbitrary support. What is needed is a beginning point and an end
point of y(n). Given finite duration x(n) and h(n), it is easy to determine these points. Let
be two finite-duration sequences. Then referring to the above set of sequences we observe that the
beginning and end points of y(n) are
respectively. A simple modification of the conv function, called conv m, which performs the convolution
of arbitrary support sequences can now be designed.
An alternate method in MATLAB can be used to perform the convolution. This method uses a matrix-
vector multiplication approach. When the sequences x(n) and h(n) are of finite duration Nx and Nh,
respectively, then their linear convolution (3.1) can also be implemented using matrix-vector
multiplication. If elements of y(n) and x(n) are arranged in column vectors x and y respectively, then
from (3.1) we obtain
y=H*x
Laboratory 2: Convolution and Discrete Functions 2.3
where linear shifts in h(nk) for n = 0…..Nh-1 are arranged as rows in the matrix H. This matrix has an
interesting structure and is called a Toeplitz matrix. A topeplitz matrix represents a diagonally shifted
impulse response.
Difference Equations
An LTI discrete system can also be described by a linear constant coefficient difference equation of the form
If aN ≠ 0, then the difference equation is of order N. This equation describes a recursive approach for computing
the current output, given the input values and previously computed output values.
where zk, k = 1, ….N are N roots (also called natural frequencies) of the characteristic equation
The particular part of the solution, yP (n), is determined from the right-hand side of (3.4). A function called filter is
available to solve difference equations numerically, given the input and the difference equation coefficients. In its
simplest form this function is invoked by
>> y = filter(b,a,x)
where
are the coefficient arrays from the equation given in (3.4), and x is the input sequence array. The output y has the
same length as input x. One must ensure that the coefficient a0 not be zero. To compute and plot impulse
response, MATLAB provides the function impz. When invoked by simplest form this function is invoked by
>> h = impz(b,a,n);
it computes samples of the impulse response of the filter at the sample indices given in n with numerator
coefficients in b and denominator coefficients in a. When no output arguments are given, the impz function plots
the response in the current figure window using the stem function.
Laboratory 2: Convolution and Discrete Functions 2.4
Main Lab
3B: Investigate this matrix, consider the sequences
x[n] = [1, 2, 3, 4, 5] and h[n] = [6, 7, 8, last digit of your roll number]
1. Determine the linear convolution y(n) = h(n) * x(n) using function conv_m.
2. Express x(n) as a 5*1 column vector x and y(n) as a 8*1 column vector y. Now determine the 8*5
matrix H so that y = Hx using function convtp.
3. Characterize the matrix H. From this characterization can you give a definition of a Toeplitz
matrix?
4. What can you say about the first column and the first row of H?