2dix-The Student Choice
Log in Register now

To develop a program for computing circular convolution Using MATLAB

PROGRAM:

%circular convolution program:

clc;
clear all;
close all;
disp('circular convolution program');
x=input('enter i/p sequence x(n):');
a=length(x);
disp(a);
h=input('enter i/p sequence h(n):');
b=length(h);
disp(b);
subplot(2,2,1), stem(x);
title('i/p sequence x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');grid;
subplot(2,2,2), stem(h);
title('i/p sequence h(n)is:');
xlabel('---->n');
ylabel('---->h(n)');grid minor;
disp('circular convolution of x(n) & h(n) is y(n):');
if(a>b)
n=a;
else
n=b;
end
if(a-b~=0)
if(a>b)
h=[h,zeros(1,a-b)];
else
x=[x,zeros(1,b-a)];
end
end
disp(x);
disp(h);
y=zeros(1,n);
for i=1:n
y(i)=0;
k=i;
for j=1:n
y(i)=y(i)+(x(j)*h(k));
if k==1
k=n+1;
end
k=k-1;
end
end
subplot(2,2,[3,4]),stem(y);
title('circular convolution of x(n) & h(n) is:');
xlabel('---->n');
ylabel('---->y(n)');grid;
disp(y);

 

comments (0)

avatar