ECE 220: Continuous-Time Signals and Systems
Spring 2020
Lab 2
Due Date
Refer to the ECE 220 Laboratory Schedule for your section to determine the report due date. Submit via Black-
oard.
Description
The purpose of this project is to learn how to use Matlab to implement the convolution integral numerically. You
will gain more practice with convolution, and see an application of convolution in implementing an acoustic
model of a room or other performance space.
1 Prela
Before starting on the lab exercises below, review section 2.2.1 in the Signals and Systems text by Oppen-
heim/Willsky/Nawab. Also prior to beginning the lab, determine and sketch the convolution y(t) = x(t) ∗ h(t)
when h(t) and x(t) are as defined below:
h(t) = u(t) x(t) = e−tu(t).
2 Numerical Approximation to Convolution
The continuous-time convolution integral is defined as follows:
y(t) =
∫ +∞
−∞
x(τ)h(t− τ)dτ. (1)
In order to use Matlab to implement the convolution integral, it is helpful to model the signals x(t) and h(t) as
piecewise-constant functions. Following section 2.2.1 of the Oppenheim/Willsky/Nawab textbook, the signal
x(t) can be approximated by x̂(t):
x̂(t) =
+∞∑
k=−∞
x(k∆)δ∆(t− k∆), (2)
where the short rectangular pulse δ∆(t) is defined as follows
δ∆(t) =
{
1 −∆/2 ≤ t < ∆/2
0 otherwise
(3)
Note that the definition of δ∆(t) in Equation 3 differs slightly from that of the textbook, but the basic idea is the
same. The signal h(t) can be approximated in a similar manner, i.e.,
ĥ(t) =
+∞∑
k=−∞
h(k∆)δ∆(t− k∆), (4)
In other words, x(t) and h(t) are approximated as a series of na
ow rectangular pulses with heights determined
y the values of the functions sampled at the center of each rectangular pulse. Figure 1 shows x̂(t) and ĥ(t)
XXXXXXXXXX XXXXXXXXXX
0
0.5
1
1.5
2
t
x
(t
)
XXXXXXXXXX XXXXXXXXXX
0
0.5
1
1.5
2
t
h
(t
)
Figure 1: Piecewise-constant approximations to the signals x(t) and h(t). These approximations were com-
puted with ∆ = 0.25.
computed using ∆ = 0.25, thus there is a short pulse located every 0.25 seconds. Obviously the approximations
will improve as ∆ is reduced.
The goal of this section is to compute the convolution of these piecewise-constant signals, i.e., to compute
ŷ(t) defined as
ŷ(t) =
∫ +∞
−∞
x̂(τ)ĥ(t− τ)dτ. (5)
Matlab can’t compute a continuous function, but it can compute samples of a function. Fortunately, if we choose
to compute the samples of ŷ(t) located ∆ seconds apart, the calculations will be simplified substantially. In
other words, we’ll focus on computing the samples ŷ(n∆) for n = 0, 1, 2, . . . Consider the equation for ŷ(1∆):
ŷ(1∆) =
∫ +∞
−∞
x̂(τ)ĥ(1 − τ)dτ. (6)
To compute this integral, we need ĥ(1 − τ), which is shown in Figure 2. From Figures 1 and 2 we can see that
the piecewise-constant sections of x̂(τ) and ĥ(1− τ) are perfectly aligned. Multiplication of x̂(τ) and ĥ(1− τ)
yields another piecewise-constant function, and computing the integral is very easy to do. (Remember that an
integral co
esponds to the area under a function, and it is easy to compute areas of rectangles.) Whenever t is
equal to a multiple of ∆ (i.e., t = n∆) the functions will be aligned and the integral will be easy to compute.
1. Starting from the convolution sum, show how that the desired samples of ŷ(t) can be computed as follows
ŷ(n∆) = ∆
+∞∑
k=−∞
x(k∆)h((n− k)∆). (7)
Note that this equation should be familiar from your work in ECE 201. It is the discrete convolution sum!
Matlab provides a function called conv that computes discrete convolution sums. Type help conv to
ead more about this function.
XXXXXXXXXX XXXXXXXXXX
0
0.5
1
1.5
2
Ï„
h
(1
−
Ï„
)
Figure 2: Piecewise-constant approximation to the signal h(1−τ). The approximation was computed assuming
∆ = 0.25.
2. Define the vector x1 to be samples of the signal x(t) defined in the prelab for 0 ≤ t ≤ 10. Similarly
define the vector h1 to be samples of the signal h(t) for 0 ≤ t ≤ 10. (Remember that Matlab indexes
its vectors starting at 1, so the n = 0 sample will be x1(1)). Use the conv function to compute y1
defined by the convolution given in Equation 7.
Note that because x1 and h1 are finite-length segments of infinite length signals, only a finite-length
segment of y1 will be valid. For what values of t does y1 represent a good approximation to the y(t)
you found in the prelab?
3. Re-do the calculations in part b for several values of ∆: ∆ = 0.25, 0.1, and 0.01. Plot your results
on a single graph, along with the exact results you found in the prelab. Comment on how well the
approximations work for different values of ∆.
4. For x(t) = t(u(t)− u(t− 8)) and h(t) = u(t)− u(t− 12), determine the convolution analytically. Find
the convolution by representing the signals as piece-wise continuous functions as above. Does it match
with your analytical prediction? What value of ∆ did you choose?
3 Using convolution to model an acoustic system
In this part of the lab you will use convolution to simulate what you would hear when someone speaks or sings
in particular room (or other acoustic environment). What you hear includes the sound produced by the person
and the sum of all the reflections of that sound off the walls and other objects in the room. Reve
eration is
the term used to describe the sum of the reflected sound. In this lab you will model the reve
eration effects
of a room as a linear time-invariant system (LTI) that is characterized by its impulse response. You will use
convolution to implement the LTI system and compute the output for a given acoustical input signal. In audio
engineering, this type of simulation is often refe
ed to as auralization.
1. Visit the website to read more about auralization and to download impulse responses for two different
environments that you would like to simulate. Make plots of those impulse responses in MATLAB and
comment on their features. Based on the impulse response, say what you expect to hear if you sang/spoke
in that environment. Note that your plots should co
ectly show the time axis for the impulse response
signals. Pay careful attention to the sampling frequency that was used to obtain the data.
2. Download the recording of the anechoic voice from the website. Load it into MATLAB and plot and play
the signal. You will use this voice in some of your simulations.
http:
openairlib.net
http:
openairlib.net
3. Write a function to compute the output of your room simulation given an input signal and the impulse
esponse signal. Include a copy of your function in the report, along with a description of how you
verified that it was working.
4. Test your function with the anechoic voice sample and the impulse responses for the two rooms. Play
the outputs in MATLAB and plot the output signals. Describe what you hear. Does the output sound like
you expected it to?
5. In this final part of the project you will record the impulse response for a room/environment of you
choice. First
ainstorm about how to create an impulse so that you can record it using the same software
you used in Lab 1. Describe your approach to measuring the impulse response in the report.
6. Record the impulse response for the environment you selected. Include plots of the measured impulse
esponse along with a description of the room and your test setup. Please include a picture of the room
in your report.
7. Make a short recording of your own voice to use in simulations. You should use the recording software
you used last time. Include a plot of your voice in the report.
8. Run your voice through the room simulator function using your measured input. Does the output sound
like what you expected? Why or why not?
4 Acknowledgment
The first part of this assignment was motivated by a similar project in the book Computer Explorations in
Signals and Systems Using Matlab by John R. Buck, Michael M. Daniel, and Andrew C. Singer.
ECE 220 Lab 2 Check-Off Sheet
Name:
Lab Section:
Show the TA that your analytical predictions for the two convolution problems match the results you
got numerically.
Run the anechoic voice and your own voice sample through the room simulator function (using im-
pulse response downloaded from the website and the impulse response of a room recorded by you).
Play the outputs to your TA.
What did you use as your impulse function to record the impulse response of the room?
TA signature and date:
TA comments:
Prela
Numerical Approximation to Convolution
Using convolution to model an acoustic system
Acknowledgment