You are on page 1of 14

Paper ID #20288

Exercises in Continuous-Time Convolution


Dr. Anthony M. Richardson, University of Evansville
Anthony Richardson has been teaching engineering for over 20 years. He joined the electrical engineering
department at the Univerisity of Evansville in 2000. His interests are in signal processing and communi-
cations.

American
c Society for Engineering Education, 2017
Exercises in Continuous-Time Convolution
- A Basis Function Approach

Continuous-time convolution is one of the more difficult topics that is taught in a Signals and
Systems course. This paper presents several analytical and MATLAB based assignments that
help students develop a better understanding of continuous-time convolution.

In the first assignment students are introduced to a set of basis functions that can be used to
compose any piece-wise polynomial signal. (Such signals include step and ramp functions as
well as rectangular, triangular and trapezoidal pulses.) Each basis function can be represented by
a triplet of numbers (amplitude, delay, and order) and any piece-wise polynomial signal can be
represented as an n x 3 array (with each row in the array corresponding to a single basis
function). MATLAB routines accept the array representation and an array of time values as
input arguments and return an array of function values.

Convolution between members of this particular set of basis functions can be performed exactly
using only simple addition and multiplication operations (no integration is required). Piece-wise
polynomial signals can be convolved using corresponding operations on their array
representations. These operations can be easily performed analytically. MATLAB routines can
also be used to compute the exact continuous-time convolution of any pair of piece-wise
polynomial signals from their basis function representation. In a second assignment, students
analytically convolve several interesting piece-wise polynomial signals using conventional
convolution (integration) methods and compare their results to those obtained using the basis
function representation and the corresponding convolution operations. The basis function results
can be found from pencil-and-paper calculations or computed using MATLAB.

MATLAB can also be used to approximately compute the continuous time convolution of a
wider class of signals than the piece-wise polynomial class. In a third assignment students
compare the results of analytical convolution to those obtained approximately using MATLAB
and also to those obtained from circuit simulation.

Theory Review

A set of generalized delta functions1, 2 can be defined as:

δ 0 (t ) = δ (t)
t

δ 1(t ) = ∫ δ 0 ( τ)d τ=u (t)


−∞
t
δ 2 (t ) = ∫ δ1 ( τ)d τ=t u (t)
−∞
t
1
δ 3(t ) = ∫
−∞
δ2 ( τ)d τ= t 2 u (t )
2

More generally:
t
1 n
δn +1 (t) = ∫ δn (τ )d τ
−∞
=
n!
t u (t )

We can view the relationship between δn(t) and δn+1(t) as the relationship between the input and
output of a single integrator system with impulse response:
i
h 1(t ) = u (t) = δ1 (t )

The impulse response of a cascade of n integrators would then be:


i
h n (t) = δ n (t)

Since the integrator is linear and time-invariant, we have the following relationship between the
input x(t) = a1 δm(t + t1) and a system with impulse response h(t) = a2 hin(t + t2)
i
a 1 a 2 δ m+ n (t+t 1 +t 2) = (a 1 δm (t +t 1))∗(a 2 hn (t+t 2 ))

This results in the following relationship for convolution of generalized delta functions:

a 1 a 2 δ m+ n (t+t 1 +t 2) = (a 1 δm (t +t 1))∗(a 2 δn (t +t 2))

Similarly, if we define the nth derivative of δ(t) (δ0(t)) as δ–n(t), the impulse response of n
cascaded differentiators is hdn(t) = δ– n(t) and

a 1 a 2 δ m−n (t+t 1 +t 2) = (a 1 δm (t +t 1))∗( a 2 δ−n (t +t 2))

Just as convolving a function with δ1(t) yields the integral of that function, convolving with δ-1(t)
gives the derivative of the function.

MATLAB Implementation

A library3 of MATLAB routines has been written to simplifying working with generalized delta
functions. The delta(n, t) function accepts as arguments an integer n (the order of the delta
function) and a time vector t. The routine returns a vector containing the corresponding function
evaluated at the times contained in the input time vector. This function is most useful when
plotting the delta functions.

For convolution of delta functions in MATLAB an array representation is desirable. The three-
element row vector x = [ a, m, td ] is used to represent the delta function x(t) = a δm(t + td). A
function of the form
M
x (t) = ∑ a i δm (t +t i)
i
i=1
is represented as an M x 3 array (called the drep representation of the signal):

[ ]
a1 m1 t1
x = a2 m2 t2
⋮ ⋮ ⋮
aM mM tM

The routine drep_func(t, x) accepts a time vector and a delta function representation array as
inputs and returns a vector containing the corresponding function evaluated at the times
contained in the input time vector.

The convolution of functions of the form


M
x (t) = ∑ a 1 i δ m (t+ t1 i )
i
i=1

and
N
h (t) = ∑ a 2 j δn (t +t 2 j )
j
j =1

is equal to
M N
y (t) = ∑ ∑ a 1 i a 2 j δ m + n (t+ t1 i +t 2 j )
i j
i =1 j=1

The function y(t) can be represented using an MN x 3 delta representation array. (Rows
corresponding to delta functions of the same order and delay can be combined to yield an array
with fewer than MN rows.). The routine drep_conv(x, h) accepts as input arguments the drep
array representations for x and h and returns a drep representation for y.

1. Classroom Application and Examples

Function composition is covered very early in our Linear Systems course. In one of the first
assignments students are asked to express several piece-wise linear signals in terms of scaled,
and time-shifted unit step and unit ramp functions. For example the signal shown in Figure 1 can
be represented as:

f 1 (t) = u (t+ 1)+2 r (t +0.5)−4 r ( t)+2 r (t−0.5)−u (t−1)

The generalized delta functions can be used as a set of basis functions to represent any piece-
wise polynomial signal. To familiarize the students with the routines in the generalized delta
function library the students are asked to also represent the signals using the generalized delta
function notation. The function in Figure 1 can be represented as:
f 1 (t) = δ1 ( t+1)+ 2 δ2 (t +0.5)−4 δ2 (t )+ 2 δ2 (t −0.5)−δ1 (t−1)

Students are asked to verify the representation by reproducing Figure 1 by writing a MATLAB
routine that uses the delta routine to implement the function. The MATLAB function is simply:

function r = f1(t)
r = delta(1,t+1) + 2*delta(2, t+0.5) - …
4*delta(2, t) + 2*delta(2,t-0.5) - delta(1,t-1);
end

The plot can be created using the following MATLAB commands:

t = -2:0.01:2;
plot(t, f1(t));

In the same exercise students are asked to plot the signal from the drep array representation using
the drep_func. This can be done using the following code:

f1_rep = [ 1 1 1
2 2 0.5
-4 2 0
2 2 -0.5
-1 1 -1 ];

t = -2:0.01:2;
plot(t, drep_func(t, f1_rep));

Figure 1: Example Piece-wise Linear Function

2. Convolution of Piece-wise Polynomial Functions

In a second exercise the students are asked to complete several problems involving convolution
of piece-wise polynomial signals (those that have a drep representations). The time-shift that
occurs when convolving with δ(t – t0) is easily demonstrated. The result of convolving the
previously defined function f1(t) with f2(t) = δ(t – 2) is shown in Figure 2.
Figure 2: Convolution of f1(t) with δ(t – 2)

This figure is produced using the following commands:

f2_rep = [ 1 0 -2];
y_rep = drep_conv(f1_rep, f2_rep);
t = -2:0.01:4;
plot(t, drep_func(t, y_rep));

In another exercise, students are asked to convolve x(t) = 2 rect(t/2) with h(t) = rect(t/4). These
two signals are shown in the top two graphs of Figure 3. First students find the result by
evaluation of the convolution integral. This leads to:

{
0 t≤−3
2 (t+ 3) −3<t≤−1
y (t) = 4 −1<t ≤1
2(3−t) 1< t≤3
0 t> 3

This signal is shown in the bottom graph in Figure 3.

Next, students do the convolution analytically using generalized delta functions. The input
signal and the impulse response can be written as x(t) = 2 δ1(t + 1) – 2 δ1(t – 1) and h(t) = δ1(t +
2) – δ1(t – 2). Convolving each term in h(t) with x(t) and combining the results yields:

y (t) = 2 δ2 (t +3)−2 δ 2 (t+1)−2 δ2 (t−1)+2 δ 2(t−3)

This function is easily graphed using MATLAB and the delta function.

Finally, students do the convolution using the MATLAB representation of the generalized delta
functions and the drep_conv function. The code to do the convolution and the plot the graph is:

x_rep = [ 2 1 1; -2 1 -1 ];
h_rep = [ 1 1 2; -1 1 -2 ];
y_rep = drep_conv(x_rep, h_rep);
plot(t, drep_func(t, y_rep));

In a related exercise students are asked to determine and graph the derivative of y(t) and compare
the result to that obtained by convolving y(t) with δ–1(t). Using delta function notation the result
is simply:

d
z (t) = y (t)
dt

= y (t )∗δ−1 (t )

= 2 δ1 (t+3)−2 δ1 (t+ 1)−2 δ1 (t−1)+2 δ1 (t−3)

The function z(t) is shown in Figure 4. This same result can be obtained using the delta function
representation in MATLAB with the following code:

z_rep = drep_conv([1 -1 0], y_rep);


plot(t, drep_func(t, z_rep));

The graph produced is identical to the one shown in Figure 4.

In yet another exercise, students are asked to verify the Central Limit Theorem. The Theorem
states that the distribution of the sum of independent, identically distributed random variables
converges to a normal distribution as the number of terms in the sum approaches infinity. The
distribution of a sum of independent random variables is equal to the convolution of the
distributions of the terms in the sum. Repeated convolutions are easy to compute using
MATLAB, the delta function representation and the drep_conv routine. Since the Central Limit
Theorem is often demonstrated for uniformly distributed random variables, the students are
asked to verify the theorem for a piece-wise polynomial (but non-uniform) distribution function.
A typical result is shown in Figure 5. The distribution shown in the upper left is:

1 1
f (t) = δ 2 (t+ 1)−δ2 (t)− δ 1( t)− δ1 (t−1)
2 2

The result of convolving two, three and then four instances of f(t) are shown in the upper-right,
lower-left, and lower-right respectively. The similarity to a normal distribution is apparent.
Figure 3: Convolution of Two rect Functions

Figure 4: Differentiation via Convolution with δ–1(t)

3. Convolution of Other Functions

Another routine provided in the library is the ct_conv routine. This routine uses the discrete-
time conv function to approximately calculate the continuous time convolution of any two pulse-
type signals. The two signals are arbitrary, i.e. they do not have to be piece-wise polynomial or
have a drep representation. The calling syntax for the routine is:

[y t] = ct_conv(f1, f2, TDOM, Ts)

f1 and f2 are handles to the continuous-time MATLAB functions, TDOM is a two element
vector containing the beginning and ending times over which the convolution is computed. Ts is
the sampling interval at which the convolution is computed (the two signal are sampled and the
discrete-time conv function is used to approximately calculate the continuous-time convolution).

This function is very useful for verifying theoretical results. For example, the convolution of
f1(t) = e – t u(t) and f2(t) = u(t) is equal to y(t) = (1 – e – t ) u(t). This can be verified quite simply
with the following MATLAB code which plots both the theoretical result and the result from the
ct_conv routine:

f1 = @(t) exp(-t).*delta(1,t);
f2 = @(t) delta(1, t);
% Define the theoretical result
yt = @(t) (1 - exp(-t)) .* delta(1,t);
% Compute the convolution using ct_conv
[y t] = ct_conv(f1, f2, [-2 8], 0.01);

plot(t, y);
hold on;
plot(t, yt(t));
hold off;

Figure 5: Verification of the CLT via Repeated Convolution

The result is shown in the bottom graph of Figure 6. The theoretical result and the result from
ct_conv overlap. f1(t) is the impulse response of a series RC circuit with a time constant of 1 s
(the output is the voltage across the capacitor). The same result can be obtained from circuit
simulation software. Having the students obtain the result from circuit simulation helps to
remind them that convolution provides useful results in the real world. The result from a circuit
simulation program (LTSpice4) is shown in Figure 7.

Figure 6: Verification of Theoretical Convolution

Figure 7: Corresponding Simulated Output From an RC Circuit

As another example consider convolving f1(t) = e – t u(t) and f2(t) = sin(π t) rect((t – 1)/2). These
two functions are shown in the top two graphs of Figure 8. The theoretical convolution is
challenging to calculate, but is equal to:
{
0 t≤0
1
[sin( π t)−π cos (π t)+ π e−t ] 0<t≤2
y (t) = 2
π +1
π (1−e 2 ) e−t t> 2
2
π +1

The MATLAB code to compute the convolution using ct_conv and compare with the theoretical
result is:

f1 = @(t) exp(-t).*delta(1,t);
f2 = @(t) sin(pi*t).*(delta(1, t) - delta(1, t-2));
% Define the theoretical result
yt = @(t) (sin(pi*t)-pi*cos(pi*t)+pi*exp(-t))/(pi*pi+1) ...
.*(delta(1,t)-delta(1,t-2)) + ...
(pi/(pi**2+1))*(1-exp(2))*exp(-t).*delta(1,t-2);
% Compute result via ct_conv
[y t] = ct_conv(f1, f2, [0 8], 0.01);
plot(t, y);
hold on;
plot(t, yt(t));
hold off;

The theoretical and MATLAB computed convolutions are shown in the bottom graph of
Figure 8. They overlap, verifying the theoretical result. The response can also be obtained using
circuit simulation. The LTSpice simulated response of the previously described series RC circuit
to a sinusoidal pulse is shown in Figure 9.

There are several interesting convolution properties of the sinc(t) = sin(π t)/(π t) signal that can
be illustrated with the ct_conv function. (Note: Several texts define sinc(t) as sin(t)/(t), the
definition being using here is the same as that used by MATLAB.) For example the convolution
of f1(t) = a sinc(a t) with itself is equal to f1(t), i.e. f1(t) is an idempotent of convolution. More
generally, when f1(t) = a sinc(a t) and f2(t) = b sinc(b t) then f1(t) * f2(t) = f1(t) if a ≤ b. These
properties are trivial to derive in the frequency domain (the transform of a sinc(a t) is
rect(ω/2πa)), but are very difficult to derive in the time domain via direct evaluation of the
convolution integral. This result is often unexpected by Figure 10 shows the result of using
ct_conv to verify the previous property with a = 1 and b = 2. The theoretical result and the
ct_conv result are both shown in the bottom graph and overlap. The MATLAB code to produce
the result is simply:

f1 = @(t) sinc(t);
f2 = @(t) 2*sinc(2*t);
[y t] = ct_conv(f1, f2, [-10 10], 0.01);
plot(t, y);
hold on;
plot(t, f1(t));
hold off;
Students are often surprised to see that the convolution of f1(t) = a sinc(a t) and f2(t) = b sinc(b t)
cos(ωo t) is equal to zero if ωo ≥ (a + b)π. This is due to modulation of b sinc(b t) by cos(ωo t)
which causes the corresponding Fourier transform of b sinc(b t) to be shifted up in frequency so
that there is no overlap between non-zero portions of the transforms of f1(t) and f2(t). The
corresponding product is zero. The convolution result is shown in Figure 11 where, again, a = 1
and b = 2. The modulation frequency ωo is 3π. The MATLAB code is simply:

f1 = @(t) sinc(t);
f2 = @(t) 2*sinc(2*t).*cos(3*pi*t);
[y t] = ct_conv(f1, f2, [-10 10], 0.01);

plot(t, y);

Figure 8: Convolution of Delayed Exponential and Sinusoidal Pulses

Figure 9: Simulated Response of Series RC Circuit to a Sinusoidal Pulse


Figure 10: Convolution of Two sinc Signals

Figure 11: Convolution of a sinc and a Modulated sinc


References

1) B.P. Lathi, Linear Systems and Signals, 2nd ed., Oxford University Press, New York, 2005

2) C.L. Phillips, J.M. Parr, E.A. Riskin, Signals, Systems, and Transforms, 5th ed., Pearson, 2013

3) Signals Software Library, csserver.evansville.edu/~richardson, web, 25 April, 2017

4) LTSpice Circuit Simulation Software, www.linear.com/designtools/software, web, 25 April,


2017

You might also like