CIRCULAR CONVOLUTION MATLAB PROGRAM

CIRCULAR CONVOLUTION


 

function f=circonv(a,b)

a=input('enter the first sequence=')

b=input('enter the second sequence=')

N1=length(a)

N2=length(b)

N=max(N1,N2)

a=[a zeros(1,N-N1)]

b=[b zeros(1,N-N2)]

for n=0:N-1

f(n+1)=0

for i=0:N-1

j=mod(n-i,N)

f(n+1)=f(n+1)+a(i+1)*b(j+1)

end

end

subplot(2,2,1)

stem(a)

xlabel('time index')

ylabel('amplitude')

subplot(2,2,2)

stem(b)

xlabel('time index')

ylabel('amplitude')

subplot(2,1,2)

stem(f)

xlabel('time index')

ylabel('amplitude')

title('circular convolution of two sequence')


 


 


 


 

OBSERVATION:


 

>> circonv(a,b)

enter the first sequence=[1,2,3]

a = 1 2 3

enter the second sequence=[1,2,3,4]

b = 1 2 3 4

N1 = 3

N2 = 4

N = 4

a = 1 2 3 0

b = 1 2 3 4

f = 0

j = 0

f = 1

j = 3

f = 9

j = 2

f = 18

j = 1

f = 18

f = 18 0

j = 1

f = 18 2

j = 0

f = 18 4

j = 3

f = 18 16

j = 2

f = 18 16

f = 18 16 0

j = 2

f = 18 16 3

j = 1

f = 18 16 7

j = 0

f = 18 16 10

j = 3

f = 18 16 10

f = 18 16 10 0

j = 3

f = 18 16 10 4

j = 2

f = 18 16 10 10

j = 1

f = 18 16 10 16

j = 0

f = 18 16 10 16

ans = 18 16 10 16

0 comments: