You are on page 1of 5

Convolution

Convolution is a mathematical operation used to express the relation


between input and output of an LTI system. It relates input, output and
impulse response of an LTI system as

y(t)=x(t)∗h(t)y(t)=x(t)∗h(t)

Where y (t) = output of LTI

x (t) = input of LTI

h (t) = impulse response of LTI

Discrete Convolution

y(n)=x(n)∗h(n)
=Σ∞k=−∞x(k)h(n−k)=Σk=−∞∞x(k)h(n−k)
(or)

=Σ∞k=−∞x(n−k)h(k)=Σk=−∞∞x(n−k)h(k)
By using convolution we can find zero state response of the system.

Discrete Convolution:
Let us see how to calculate discrete convolution:

i. To calculate discrete linear convolution:

Convolute two sequences x[n] = {a,b,c} & h[n] = [e,f,g]


Convoluted output = [ ea, eb+fa, ec+fb+ga, fc+gb, gc]

Note: if any two sequences have m, n number of samples respectively,


then the resulting convoluted sequence will have [m+n-1] samples.

Example: Convolute two sequences x[n] = {1,2,3} & h[n] = {-1,2,2}

Convoluted output y[n] = [ -1, -2+2, -3+4+2, 6+4, 6]

= [-1, 0, 3, 10, 6]

Here x[n] contains 3 samples and h[n] is also having 3 samples so the
resulting sequence having 3+3-1 = 5 samples.

Linear Convolution With Build in Function:

clc;
clear all;
close all;
x=input('ENTER THE FIRST SEQUENCE ');
h=input('ENTER THE SECOND SEQUENCE ');
y=conv(x,h);
stem(y);
xlabel('Amplitude---->');
ylabel('time----->');
title('LINEAR CONVOLUTION');
Output

enter the x(n) sequence [ 1 2 3 4]


enter the h(n) sequence [ 1 2 3 4]

Fig 14: Linear Convolution

ii. To calculate periodic or circular convolution:

Periodic convolution is valid for discrete Fourier transform. To calculate


periodic convolution all the samples must be real. Periodic or circular
convolution is also called as fast convolution.

If two sequences of length m, n respectively are convoluted using circular


convolution then resulting sequence having max [m,n] samples.

Ex: convolute two sequences x[n] = {1,2,3} & h[n] = {-1,2,2} using
circular convolution

Normal Convoluted output y[n] = [ -1, -2+2, -3+4+2, 6+4, 6].

= [-1, 0, 3, 10, 6]

Here x[n] contains 3 samples and h[n] also has 3 samples. Hence the
resulting sequence obtained by circular convolution must have max[3,3]= 3
samples.
Now to get periodic convolution result, 1st 3 samples [as the period is 3] of
normal convolution is same next two samples are added to 1st samples as
shown below:

∴ Circular convolution result y[n]=[9 6 3]

Circular Convolution with out Build in function:

clc;
clearall;
closeall;
% input
x=input('Enter first sequence in matrix form: ');
h=input('Enter second sequence in matrix form: ');
L=length(x);
M=length(h);
N=max(L,M);
N1=L-M;
%zero pading
if(N1>=0)
h=[h,zeros(1,N1)];
else
x=[x,zeros(1,N1)];
end
if(N1<0)
x=[x,zeros(1,-N1)];
%circular shifting and convolution
for n=1:N
y(n)=0;
for i=1:N
j=n-i+1;
if(j<=0)
j=N+j;
end
y(n)=[y(n)+x(i)*h(j)];
disp(y);
end
end
%plot the inputs and output
n=0:N-1;
subplot(3,1,1);
stem(n,x);
xlabel('n');
ylabel('x(n)')
subplot(3,1,2);
stem(n,h);
xlabel('n');
ylabel('h(n)')
subplot(3,1,3);
stem(n,y);
xlabel('n');
ylabel('y(n)');

Output

enter the x(n) sequence [ 1 2 3 4]


enter the h(n) sequence [ 1 2 3 4]

Fig 15: Circular Convolution Without Build in Function.

You might also like