Circularconvolution
Circularconvolution
clc;
clear all;
close all;
x=input('Enter the input sequence: ');
h=input('Enter the second sequence: ');
l=length(x);
m=length(h);
N=max(l,m);
x=[x zeros(1,N-l)];
h=[h zeros(1,N-m)];
x=x';
d=[];
for i=0:N-1
d=[d circshift(x,i)];
end
y=d*h';
disp('Circular Convolution using Matrix Multiplication:');
disp(y);
x1=[x zeros(1,N-L)];
h1=[h zeros(1,N-M)];
Y=X.*H;
disp('Multiplication of X & H');
disp(Y);
clc;
clear all;
close all;
x=input('Enter the sequence of x : ');
h=input('Enter the sequence of h : ');
l1=length(x);
l2=length(h);
N=l1+l2-1;
x1=[x zeros(1,(N-l1))];
h1=[h zeros(1,(N-l2))];
xt=x1';
d=[];
for i=0:1:N-1
d=[d circshift(xt,i)];
end
y=d*h1';
disp('Linear Convolution using Matrix method:')
disp(y);
clc;
clear all;
close all;
x=input('Enter the sequence of x : ');
h=input('Enter the sequence of h : ');
L=length(x);
M=length(h);
N=L+M-1;
x1=[x zeros(1,N-L)];
h1=[h zeros(1,N-M)];
Y=X.*H;
disp('Multiplication of X & H');
disp(Y);