Ministry of Higher Edu. & Scie.
Research وزارة التعليم العالي والبحث العلمي
Al-Mustansiriyah University الجامعة المستنصرية
Engineering Faculty كلية الهندسة
Computer Engineering Department قسم هندسة الحاسوب
Experiment No. (10) - Convolution
Experiment No. (10) - Convolution
Object
In this lab you will review the concept of convolution, and learn how to convolve
signals in matlab. You will learn more about discrete-time convolution and
discrete-time methods in matlab.
Theory
Convolution can be evaluated in many different ways. If the sequences are
mathematical functions (of finite or infinite duration), then we can analytically
evaluate the following equation for all n to obtain a functional form of y(n).
y(n) = x(n)*h(n)
y(n) = LTI [x(n)] =
=∑ ( ) ( )
Where x(n) is the input to the circuit, y(n) is the output of the circuit and h(n) is
the impulse response of the circuit.
matlab has a function called conv(x,h) that you can use to convolve two signals
x(n) and h(n). It assumes that the time increment is the same for both signals. The
input signals are finite-length, so the result of the convolution should have a length
equal to the sum of the lengths of the inputs length(x) + length(h) - 1. , a linear
time-invariant (LTI) system is completely described by its impulse response. When
working in matlab, this impulse response must also be discrete.
1
Ministry of Higher Edu. & Scie. Research وزارة التعليم العالي والبحث العلمي
Al-Mustansiriyah University الجامعة المستنصرية
Engineering Faculty كلية الهندسة
Computer Engineering Department قسم هندسة الحاسوب
Experiment No. (10) - Convolution
To determine the convolution y(n) = x(n) ∗ h(n), by using MATLAB scripts
follows the steps below:
1- Create function name myconv and save it as myconv;
a. Find y lower limit nyb from the values (nx1 + nh1);
b. Find y upper limit nye ( nx(length(x)) + nh(length(h) );
c. Find full limit (nyb : nye);
d. Calculate y =conv(x,h)
2- Main program
a. Insert x vector;
b. Calculate nx limits;
c. Insert h vector;
d. Calculate nh limits;
e. Call function myconv;
f. Display y, and its limit ny.
Example: Given the following two sequences:
x(n) = [3, 11, 7, 0, -1, 4, 2];
h(n) = [2, 3, 0, -5, 2, 1];
Write program in MATLAB to find the convolution y(n)
Procedure:
1- Determine the convolution y(n) = x(n) * h(n) by using MATLAB scripts,
write the program procedure and the obtained results. For the following
sequences:
( ) ( )
2
Ministry of Higher Edu. & Scie. Research وزارة التعليم العالي والبحث العلمي
Al-Mustansiriyah University الجامعة المستنصرية
Engineering Faculty كلية الهندسة
Computer Engineering Department قسم هندسة الحاسوب
Experiment No. (10) - Convolution
2- Determine the convolution y(n) = x(n) * h(n) by using MATLAB scripts,
write the program procedure and the obtained results. For the following
sequences:
( ) ( )
The sequence x is defined for the n period [-1,5].
The sequence h is defined for the n period [2,6].
3- Write program to find the convolution in MATLAB without using
conv(x,h), and using For loop instruction instead of it.
4- Find the convolution to the following signals:
3
Ministry of Higher Edu. & Scie. Research وزارة التعليم العالي والبحث العلمي
Al-Mustansiriyah University الجامعة المستنصرية
Engineering Faculty كلية الهندسة
Computer Engineering Department قسم هندسة الحاسوب
Discussion
1- Find the total response when the input function is ( ) ( ) , and the
impulse response is given by ( ) ( ) . Where n=1:10.
2- Find the total response when the input function is ( ) ( ) , and the
impulse response is given by ( ) ( ) . Where n=1:10.