Write a program to compute the circular convolution of two length-N sequences via the DFT ap-
proach. Use your DFT and IDFT programs for this purpose.
Use your programs (using calling function) to
nd the circular convolution of the following pairs of sequences:
(i) x(n) = [1; 3;-2; 4; 7], h(n) = [3; 1; 21;-3]
(ii) x(n) = n; h(n) = (0:5)^n, 0 < n <10
//i)
n=0:1:10
u1=n>=0
u2=n>=4
x=(u1-u2)
stem(n,x)
h=[1,2,0,1,-1,3]
c=cconv(x,h)
//ii)
n=0:1:10
u1=n>=0
u2=n>=4
x=(u1-u2)
h=[1,2,0,1,-1,3]
l1=length(x)
l2=length(h)
N=max(l1,l2)
x=[x zeros(1,N-l1)]
h=[h zeros(1,N-l2)]
y=zeros(1,N);
for i=0:N-1
for j=0:N-1
k = mod((i-j),N)
y(i+1) = y(i+1) + x(j+1)*h(k+1)
end
Comments
Leave a comment