%Matlab code for convolution of two signals without using conv function
close all
clear all
x=input('Enter x: ') % input x in the form [1,2,3,4,5]
h=input('Enter h: ')
m=length(x);
n=length(h);
X=[x,zeros(1,n)]; % padding of n zeros
H=[h,zeros(1,m)]; % padding of m zeros
for i=1:n+m-1
Y(i)=0;
for j=1:i
Y(i)=Y(i)+X(j)*H(i-j+1);
end
end
Y
stem(Y);
ylabel('Y[n]');
xlabel('----->n');
title('Convolution of Two Signals without conv function');
close all
clear all
x=input('Enter x: ') % input x in the form [1,2,3,4,5]
h=input('Enter h: ')
m=length(x);
n=length(h);
X=[x,zeros(1,n)]; % padding of n zeros
H=[h,zeros(1,m)]; % padding of m zeros
for i=1:n+m-1
Y(i)=0;
for j=1:i
Y(i)=Y(i)+X(j)*H(i-j+1);
end
end
Y
stem(Y);
ylabel('Y[n]');
xlabel('----->n');
title('Convolution of Two Signals without conv function');
showing error :
ReplyDelete??? Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> Assign2_p1 at 11
X=[x,zeros(1,n)];
please see asap
Where is output?
ReplyDelete