You are on page 1of 2

INSTITUTE OF BIOMEDICAL ENGINEERING & TECHNOLOGY

LIAQUAT UNIVERSITY OF MEDICAL AND HEALTH SCIENCES,


JAMSHORO
Subject: Signals & Systems Year: 3rd Term: 5th
Lab Handout – 06

Name: _________________________________ Roll No: ____________________

Score: __________ Signature of Tutor: ______________ Date:________________

CONVOLUTION IN MATLAB

LAB OBJECTIVE:
To generate a MATLAB program to find the convolution of two sequences.

CONVOLUTION:

The response y(n) of the LTI system as a function of the input signal x(n) and the unit sample
(impulse) response h(n) is a convolution sum between x(n) & h(n). The input x(n) is convolved
with the impulse response h(n) to yield the output y(n).

The Equation of Convolution:


y ( n)   x ( k ) h( n  k )
k 

y ( n )  h ( n)  x ( n )

 The convolution in Matlab is accomplished by using “conv” command.


 If “u” is a vector with length ‘n’ and “v” is a vector with length ‘m’, then their
convolution will be of length “n+m-1”
 Convolution is a commutative operation.
 Convolution in time domain corresponds to multiplication in frequency domain.

INLABTASK#01:
Clear all
Code:
u=[1 2 3 4];
v=[10 20 30];
c=conv(u,v)

Output:
c=
10 40 100 160 170 120
INLABTASK#02:
For example, given the following two sequences:
x(n) = [3,1l,7, 0,-1,4,2], -3£n£3; h(n) = [2,3,0,-5,2,1], -1£n£4

Determine the convolution y(n) = x(n) * h(n).


Code:
x = [3, 11, 7, 0, -1,4,2].
h = [2, 3, 0, -5, 2, 1];
y = conv(x,h)

Output
y=
6 31 47 6 -51 -5 41 18 -22 -3 8 2

CONVOLUTION FOR EXPONENTIAL FUNCTION:

INLABTASK#03:

x(t)= exp-o.5t u(t) Output:


Code:
T=0.005;
t=-8:T:8;
u=1*(t>=0);
plot(t,u);
grid on
x=exp(-0.5*t).*(t>=0);
plot(t,x);
y=conv(u,x);
t2=-8:T/2:8;
plot(t2,y);
grid on

POST LAB TASK:

1. Find the convolution for the following:


 X(t)=exp0.8tu(t)
Mention x,y labels, title and your roll num

INSTRUCTIONS:
 Please complete your lab reports neatly.
 All code must be commented appropriately and included in the file submitted.
 Handouts are required to be submitted by the next lab.
 Make sure your handout contains all the required information and that the file is named
correctly.

You might also like