Sei sulla pagina 1di 1

Linear convolution using matlab

clc
x=input('enter the sequence for linear convolution');
y=input('enter the seq for second');
m=length(x);
disp('length of first sequence');m
n=length(y);
disp('length of second squence');n
N=m+n-1;
disp('length of resultant sequence');N
w=zeros(1,N);
for i=1:7
for k=1:i
if((i-k+1)<5)&&(k<=4)
w(i)=w(i)+x(k)*y(i-k+1);
end
end
end
n1=1:m;
subplot(3,1,1);
stem(n1,x);
n2=1:n;
subplot(3,1,2);
stem(n2,y);
n3=1:7;
subplot(3,1,3);
stem(n3,w);
disp('result of linear convolution is');w

Potrebbero piacerti anche