You are on page 1of 4

Mehran University of Engineering and Technology, SZAB Campus, Khairpur Mir’s

Department of Electrical Engineering


Signals & Systems
Lab # 05
Name: Roll No:

Score: Signature: Date:

Convolution

OBJECTIVES:

Following are the objectives of this lab.


 To understand the concept of the convolution.
 To perform the convolution of two signals.
 To perform the convolution of two sequences.

EQUIPMENT:

 Personal Computer
 MATLAB

DISCUSSION:

INTRODUCTION:
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).


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

The convolution of the equation:

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

is implemented in MATLAB by the command, “conv”, provided the two sequences to be


convolved are of finite length. For example, the output sequence of an FIR system can be
computed by convolving its impulse response with the given finite length input sequence.

1
Example of Convolution in MATLAB:

1. Consider the following code:


%convolution
h=[5 4 3 2 1]; % first sigal
x=[1 1 1 1 1]; % second signal
c=conv(h,x); % convolution result stored in variable ‘c’
m=length(c)-1;
n=0:1:m;
stem(n,c); % plot
grid on;

Its Output is as follows:

2. Convolution of two signals:

%Convolution of two signals%


clc;
clear all;
close all;
t=0:0.001:10;
x=sin(t);
h=square(t);
subplot(3,1,1);
plot(t,x,'g');
xlabel('time');

2
ylabel('amplitude');
title('sinusoidal signal');
subplot(3,1,2);
plot(t,h,'r');
xlabel('time');
ylabel('amplitude');
title('square function');
y=conv(x,h);
subplot(3,1,3);
plot(y);
xlabel('time');
ylabel('amplitude');
title('convolution signal');

3. Convolution of two sequences:

clc;
clear all;
close all;
L=input('enter the length of 1st sequence');
M=input('enter the length of 2nd sequence');
x=input('enter the first sequence:x(n)=');
h=input('enter the second sequence:y(n)=');
N=0:(L+M-1);
y=conv(x,h);
subplot(3,1,1);
stem(x,'g');
xlabel('discrete time');
ylabel('x(n)');
title('1st sequence');
subplot(3,1,2);
stem(h,'r');
xlabel('discrete time');
ylabel('h(n)');
title('second sequence');
subplot(3,1,3);
stem(y);
xlabel('discrete time');
ylabel('y(n)');
title('convolution of two sequences');

%%%
enter the first sequence:x(n)=[1 2 3 4]
enter the second sequence:y(n)=[1 2 3 4]
%%%

3
LAB TASK:

1. Attach the graphs of Example 01 & 02.


2. Given the system’s difference equation
Y[n]=x[n]+0.5x[n-1]+0.75y[n-1]-0.5y[n-2]
Find the response to the following input
X[n]=e0.5nu[n]
3. Take x[n]=[1 2 3 2 1] and h[n]= [ 1 1 2 2 1 1] compute convolution and also check
correlation
4. Write a MATLAB code to calculate the convolution result of the following 2
sequences using any of the methods discussed in class:
n 0 1 2 3 4
h(n) 4 2 -1 3 -2
x(n) -4 1 3 7 4

Final Check List:

 Save your programs & turn off PC.


 Submit your answers to questions, and results before the next laboratory.

You might also like