To implement convolution of two Digital Signals > Matlab
To implement convolution of two Digital Signals > Matlab
Digital Signal Processing
%Convolution
clear all
x=input('Enter x :');
h=input('Enter h :');
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
x
h
Y
subplot(3,1,1);
stem(x);
title('First Signal');
subplot(3,1,2);
stem(h);
title('Second Signal');
subplot(3,1,3);
stem(Y);
title('Convolution of Two Signals');
% OUTPUT :
% Enter x :[2 2 2]
% Enter h :[1 2 3 2 1]
%
% x =
%
%
2 2 2
%
%
% h =
%
%
1 2
3 2 1
%
%
% Y =
%
%
2 6 12
14 12 6
2
%
Comments
Post a Comment