06-05-2011, 03:40 PM
Procedure:-
1) Find the length of the first sequence x[n]=x_length
2) Find the length of the first sequence h[n]=h_length
3) Take the circular convolution order as N
4) If x_length < N, pad enough number of zeros to x[n], so that the number of samples in the modified x[n]=N
5) If h_length < N ,pad enough number of zeros to h[n], so that the number of samples in the modified h[n]=N
6) Take DFT for modified x[n]=x(k)
7) Take DFT for modified h[n]=H(k)
8) Compute Y(K)=X(K)*H(K)
9) Compute y(n)=IDFT(Y(k))
10) Verify if y[n]=conv(x,h)
MATLAB program for circular convolution using DFT and IDFT
Code:
clear
clc
close all
% FIRST SEQUENCE X1
x1 = [2 3 4 1];
nx1 = 0:length(x1)-1;
n1 = length(x1);
subplot(3,1,1);
stem(nx1,x1);
xlabel('n-->');
ylabel('x1-->');
title('First Sequence');
grid on;
% SECOND SEQUENCE X2
x2 = [1 1 2 1];
nx2 = 0:length(x2)-1;
n2 = length(x2);
subplot(3,1,2);
stem(nx2,x2);
xlabel('n-->');
ylabel('x2-->');
title('Second Sequence');
grid on;
% CIRCULAR CONVOLUTION ORDER IS N
N = 4;
% if N > length(x1) or length(x2) zero pad
newx1 = [x1,zeros(1,N-n1)];
newx2 = [x2,zeros(1,N-n2)];
% TAKE DFT OF FIRST SEQUENCE
x1dft = fft(newx1);
% TAKE DFT OF SECOND SEQUENCE
x2dft = fft(newx2);
% MULTIPLY THE TWO DFTS
ydft = x1dft .* x2dft
% TAKE IDFT OF THE PRODUCT OF TWO DFTS
disp('Response obtained by DFTs')
y = ifft(ydft)
n = 0:length(y)-1;
subplot(3,1,3);
stem(n,y);
xlabel('n-->');
ylabel('x2-->');
title('circularly convoluted Sequence');
grid on;
% VERIFICATION WITH DIRECT CONVOLUTION
m = [0:N-1];
for n = 0:N-1,
g(n+1) = sum(x2(mod(n-m,N)+1).*x1);
end;
g
CIRCULAR CONVOLUTION USING DFT AND IDFT