clc;
close all;
clear all;
a1= input('1st sequence x:');
b1= input('2nd sequence h:');
q=conv(a1,b1);q
subplot(224);
stem(q);
title('Linear Convolution');
ax=length(a1);
bx=length(b1);
n=max(ax,bx);
n3=ax-bx;
if(n3<=0)
a1=[a1,zeros(1,-n3)];
else
b1=[b1,zeros(1,n3)];
end
for r=1:n
y(r)=0;
for i=1:n
j=r-i+1
if j<=0
j=j+n;
end
y(r)=y(r)+b1(j)*a1(i);
end
end
subplot(221);
stem(a1);a1
xlabel('n');
ylabel('a(n)');
title('first sequence');
subplot(222);
stem(b1);b1
xlabel('n');
ylabel('b(n)');
title('second sequence');
subplot(223);
stem(y);
xlabel('n');
ylabel('y(n)');
title('circular convolution sequence');
disp('the resultant signal is:');y
Input:
1st Sequence x:[1 2 3 4]
2nd Sequence h:[1 2]
Output:
q =
1 4 7 10 8
a1 =
1 2 3 4
b1 =
1 2 0 0
the resultant signal is:
y =
9 4 7 10
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment