CEE324L: Linear Systems and Signals Lab
Lab 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 >, =, fmin. Empty vectors, i.e., x = [] and t = [] should be returned if input
parameters are not valid.
Experiment
(0A) Write a function trainplot( ox, vx), which takes a column vector vx as input, and plots
it as shown in Fig. 4. Parameter ox is the smallest n such that x[n] is non- zero.
Fig 4. Plot generated by trainplot for vector
( 1A) Plot imag( sq_wave(19)) and imag( sq_wave(39 )) using function trainplot developed in part
(0A)
What can you say about the real part of the Fourier series, and why?
(1B) Using functions sq_wave and fs_approx, compute and plot approximations x5( t), x19( t),
x79( t) for at least one period, say for tmin = -0.5π to tmax = 1.8π.
Examine the minimum and maximum values for each approximation xN( t). What can you
conclude from the observation?
(2A) Using function trainplot, plot real and imaginary part of ak obtained with
saw_wave(19). Use Matlab function subplot so that then two plots can be shown in the same
graphic window.
(2B) Using functions saw_wave and fs_approx, plot x5(t), x20(t) and x80(t) for at least one period.
Note that for better presentation, you may want to compute and plot the approximations for tmin
= -0.2 to tmax = 1.2.
(3A) Compute and plot real( half_rect( 20)) using function trainplot. What can you say about
the imaginary part of the Fourier series, and why?
(3)
(3B) Using functions half_rect and fs_approx, compute and plot x5(t), x10(t), x20(t) and
x40(t) for at least one period, say from fmin = -12 (ms) to fmax = 12 (ms).
Report
(1)
Turn-in all Matlab work, including all .m files.
(2)
Turn-in all the graphical plots.
(3)
Discuss the results of this experiment.
(4)
(4)
For each problem, describe your approach, including all the work done by hand.
(5)
Make comments for each experiment, and answer questions.
(5)
Purchase answer to see full
attachment