0% found this document useful (0 votes)
25 views

Circularconvolution

Uploaded by

RATHIPRIYA B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Circularconvolution

Uploaded by

RATHIPRIYA B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Circular Convolution using Matrix multiplication:

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);

Circular Convolution using DFT:


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=max(L,M);

x1=[x zeros(1,N-L)];
h1=[h zeros(1,N-M)];

for k=0 : 1 :N-1


a(k+1)=0;
for n=0:1:N-1
X(k+1) = a(k+1)+x1(n+1)*exp((-1j*2*pi*n*k)/N);
a(k+1)=X(k+1);
end
end
disp('Discrete Fourier Transform x: ');
disp(X);

for k=0 : 1 :N-1


b(k+1)=0;
for n=0:1:N-1
H(k+1) = b(k+1)+h1(n+1)*exp((-1j*2*pi*n*k)/N);
b(k+1)=H(k+1);
end
end
disp('Discrete Fourier Transform h: ');
disp(H);

Y=X.*H;
disp('Multiplication of X & H');
disp(Y);

for n=0 : 1 :N-1


c(n+1)=0;
for k=0:1:N-1
y(n+1) = c(n+1)+Y(k+1)*exp((1j*2*pi*n*k)/N);
c(n+1)=y(n+1);
end
z=y/N;
end
disp('Circular Convolution using DFT :');
disp(real(z));

Linear Convolution using Matrix method:

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);

Linear Convolution using DFT:-

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)];

for k=0 : 1 :N-1


a(k+1)=0;
for n=0:1:N-1
X(k+1) = a(k+1)+x1(n+1)*exp((-1j*2*pi*n*k)/N);
a(k+1)=X(k+1);
end
end
disp('Discrete Fourier Transform x: ');
disp(X);

for k=0 : 1 :N-1


b(k+1)=0;
for n=0:1:N-1
H(k+1) = b(k+1)+h1(n+1)*exp((-1j*2*pi*n*k)/N);
b(k+1)=H(k+1);
end
end
disp('Discrete Fourier Transform h: ');
disp(H);

Y=X.*H;
disp('Multiplication of X & H');
disp(Y);

for n=0 : 1 :N-1


c(n+1)=0;
for k=0:1:N-1
y(n+1) = c(n+1)+Y(k+1)*exp((1j*2*pi*n*k)/N);
c(n+1)=y(n+1);
end
z=y/N;
end
disp('Linear Convolution by DFT:');
disp(real(z));

You might also like