Circular Convolution using DFT and IDFT ( W4 Matrix )

% W4 circular_convolution_using_dft_idft clc; x1=[1,2,3,4]; x2=[1,1,1,0]; N=4;   disp('x1(n)='); disp(x1); disp('x2(n)='); disp(x2);     % finding dft of x1 % x1k=zeros(); w4=zeros(); for i=0:N-1 for j=0:N-1 w4(i+1,j+1) = exp(complex(0,(-2*pi*i*j)/4)); end; end;   fprintf('W %d Matrix =',N); disp(w4); temp=zeros(); for i=1:N for j=1:N temp=temp+(w4(i,j).*x1(j)); end;   x1k(i)=temp; temp=0; end; disp('x1(k) = ') disp(x1k);       % finding dft of x2 % x2k=zeros(); temp=zeros(); for i=1:N for j=1:N temp=temp+(w4(i,j).*x2(j)); end;   x2k(i)=temp; temp=0; end; disp('x2(k) ='); disp(x2k);     % multiplying obtained DFT outputs X1(K)*X2(K) % Y_K=zeros(); for i=1:N Y_K(i)=x1k(i)*x2k(i); end; disp('Y(K) ='); disp(Y_K);     %finding IDFT Y(K) that is output of %circular conv.   %computing complex conjugate of w8 w4=conj(w4); disp('complex conjugate of w4'); disp(w4); y_m=zeros(); temp=zeros(); for i=1:N for j=1:N temp=temp+(1/4*(w4(i,j).*Y_K(j))); end; y_m(i)=temp; temp=0; end; disp('y_m='); disp(y_m);     %plotting subplot(3,2,1); stem(x1); title('x1(n) = Signal 1'); subplot(3,2,2); stem(x2); title('x2(n) = Signal 2'); subplot(3,2,3); stem(x1k); title('x1(K) = DFT of x1(n)'); subplot(3,2,4); stem(x2k); title('x2(K) = DFT of x2(n)'); subplot(3,2,5); stem(real(Y_K)); title(' Y(K) = x1(k) * x2(k) PRODUCT OF TWO DFTs'); subplot(3,2,6); stem(real(y_m)); title(' y(m) = IDFT of Y(K) = Circular Convolution');




Popular posts from this blog

MATLAB code for Circular Convolution using Matrix method

Positive number pipe in angular 2+