CEE324L: Linear Systems and Signals LabLab 4: Convolution Sum
Objective
To learn how to compute convolution sum in Matlab.
Background
Convolution Sum in Matlab
Let x[n] be a discrete-time signal such that x[n] = 0 for n < ox. Then x[n] can be denoted
by a pair , where vx = [ x[ox] x[ox+1 ] ... ] is an vector and x[ox] ≠ 0. In Fig.
1, x[n] =, where ox = -2 and vx = [ 1 -2]. And h[n] = , where oh = 3
and vh = [ -1 0 3 2].
Fig. l Representing general discrete time signals in Matlab
It is easy to see that if x[ n] = , then x[n-n0] = .
A built-in function vy = conv( vx, vh) is provided by M atlab to compute the convolution
sum of two vectors vx and vh. With our notation, this function actually computes
= *.
In order to use function conv to calculate convolution sum for general discrete-time signals,
a signal x[n] = must be shifted to the left for ox steps (if ox > 0), Let x1[n] =
= x[n+ox] = x[n] * δ[n+ox]. For h[n] = , we may have h1[n] =
= h[n+oh] = h[n] * δ[n+oh].
By invoking Matlab function vy = conv( vx, vh), we actually obtain
y1[n]
= = x1[n] * h1[n]
= (x[n] * δ[n+ox]) * (h[n] * δ[n+oh])
= (x[n] * h[n]) * δ[n+ox+oh]
Thus
1
x[n] * h[n] = y1[n] * δ[n-(ox+oh)]
= y1[n -(ox+oh)] =
=
Example:
For signals x[n] and h[n] shown in Fig. 1, Matlab instructions for representing these
two signals, and that for calculate the convolution sum of the two are given below.
Fig. 2 Computing convolution sum of general discrete-time signals in Matlab
Preparation
You need to read the Matlab book for the following topics:
•
•
•
•
•
more functions and commands for graphical plotting
functions conv and deconv , rand and sound
for statement and if statement in Matlab
relational operators >, =,