You are on page 1of 3

Practical - 6

AIM : To perform circular convolution on matlab


Using DFT-IDFT, equation & function.

 Function for this practical:

function[a,n]=funcircon(x,y)

N=length(x)
M=length(y)

n=M

y=fliplr(y)

for i=1:N
y=[y(1,N) y]
a(1,i)=0
for j=1:M
a(1,i)=a(1,i)+(x(1,j).*y(1,j))
end
end

~ 28 ~
 Using DFT & IDFT :

To find circular convolution of the the given sequences


using MATLAB commands like fft & ifft

x1 = input('Enter the 1st sequence:');


x2 = input('Enter the 2nd sequence:');
n = length(x1);

y1 = fft(x1);

y2 = fft(x2);

y3 = y1.*y2; %multiplication of two DFTs

a = ifft(y3);

disp('The convolution of x1 & x2 is:');a

 Using eqution

Circular Conv
clc
clear all

x=input('enter the i/p seq of x:')


y=input('enter the i/p seq of y:')

N=length(x)
M=length(y)

y=fliplr(y)

for i=1:N
y=[y(1,N) y]
a(1,i)=0
for j=1:M
a(1,i)=a(1,i)+(x(1,j).*y(1,j))
end
end

~ 29 ~
 Using function

clc
clear all

x=[1 2 3 4]
y=[2 1 2 1]
a=funcircon(x,y)
disp('a')

Input

X = [ 1 2 3 4]

Y= [ 2 1 2 1]

Output

A= [ 14 16 14 16 ]

~ 30 ~

You might also like