clc;
close all;
x1=input('Enter x1 : ');
x2=input('Enter x2 : ');
c=fcconv(x1,x2);
c
stem(c);
title('Circular convolution');
xlabel('--------> n');
ylabel('Amp');
function
function [c]=fcconv(x1,x2)
if length(x1)>length(x2)
x2=[x2, zeros(1,length(x1)-length(x2))];
else
x1=[x1, zeros(1,length(x2)-length(x1))];
end
l=length(x1);
n=1:l;
y(n)=0;
for k=1:l
p=(mod(n-k,l))+1;
y(n)=y(n)+ x1(k)*x2(p);
end
c=y;
close all;
x1=input('Enter x1 : ');
x2=input('Enter x2 : ');
c=fcconv(x1,x2);
c
stem(c);
title('Circular convolution');
xlabel('--------> n');
ylabel('Amp');
function
function [c]=fcconv(x1,x2)
if length(x1)>length(x2)
x2=[x2, zeros(1,length(x1)-length(x2))];
else
x1=[x1, zeros(1,length(x2)-length(x1))];
end
l=length(x1);
n=1:l;
y(n)=0;
for k=1:l
p=(mod(n-k,l))+1;
y(n)=y(n)+ x1(k)*x2(p);
end
c=y;
0 comments:
Post a Comment