You are on page 1of 1

x=input('Enter x: ');

h=input('Enter h: ');
n=length(x);
k=length(h);
x1=[x, zeros(1,k)]; h1=[h,zeros(1,n)]; % zero padding of both x[n] and h[n] if
size of x[n] ? size of h[n]
for r =1: n+ k -1
y(r) = 0;
for i=1:n
if(r - i+1> 0)
y(r) = y(r) + x1(i)*h1(r -i+1);
m(r) = y(r);
else
end
end
end
display('Output is:' ); m
stem(m); grid;
ylabel('y[n]');
xlabel('n');
title('Convolution without using conv function');

You might also like