Professional Documents
Culture Documents
y(t)=x(t)∗h(t)y(t)=x(t)∗h(t)
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:
= [-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.
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
Ex: convolute two sequences x[n] = {1,2,3} & h[n] = {-1,2,2} using
circular convolution
= [-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:
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