Program Code
%circular convolution
clc;
close all;
clear all;
x=input('Please enter
the first sequence x[n] = ');
h=input('Please enter
the second sequence h[n] = ');
L1=length(x);
L2=length(h);
Len=max(L1,L2);
x=[x zeros(1,Len-L1)];
h=[h zeros(1,Len-L2)];
for i=0:(Len-1)
y(i+1)=0;
for j=0:(Len-1)
m=mod(i-j,Len);
y(i+1)=y(i+1)+(x(j+1)*h(m+1));
end
end
disp('Convoluted
sequence of x[n] and h[n] is given below: ');
disp(y);
subplot(311);
stem(x);
title('First
sequence x[n]');
grid on;
subplot(312);
stem(h);
title('Second
sequence h[n]');
grid on;
subplot(313);
stem(y);
title('Convoluted
sequence ');
grid on;
Example of Output
Please enter the first sequence x[n] = [1 3 2 1]Please enter the second sequence h[n] = [2 1 2]
Convoluted sequence of x[n] and h[n] is given below:
7 9 9 10
________________________________________