Professional Documents
Culture Documents
MATLAB CODE :-
clc
clear all
close all
n=0:7
x=[1 3 2 4 6]
h=[3 3 2 1]
N=length(x)
M=length(h)
L=N+M-1
p=find(n>4)
x(p)=0
q=find(n>3)
h(q)=0
x1(:,1)=[3;3;2;1;0]
x2=[3;3;2;1;0]
for i=1:N-1
x1(:,i+1)=circshift(x2,[1 0])
x2=x1(:,i+1)
end
y=x1*x'
subplot(3,1,1)
stem(n,x,'^','r','LineWidth',3)
title({'\fontsize{20}{\color{blue}Circular Convolution Using
Matrix Method}';'\fontsize{15}{\color{green}x(n)}'})
xlabel('time-->')
ylabel('Amplitude--->')
grid on
subplot(3,1,2)
stem(n,h,'^','c','LineWidth',3)
title({'\fontsize{15}{\color{red}h(n)}'})
xlabel('time-->')
ylabel('Amplitude--->')
grid on
subplot(3,1,3)
stem(n,y,'^','m','LineWidth',3)
title({'\fontsize{15}{\color{blue}y(n)}'})
xlabel('time-->')
ylabel('Amplitude--->')
grid on
OUTPUT :-