### Circular convolution using IDFT and DFT ( using W8 matrix )

`% W8 circular_convolution_using_dft_idft%clc;x1=[1,1,1,0,0,0,0,0];x2=[0,1,2,2,1,0,0,0];N=8; % finding dft of x1 %x1k=zeros();w8=zeros(); for i=0:N-1for j=0:N-1w8(i+1,j+1) = exp(complex(0,(-2*pi*i*j)/N));end;end;fprintf('W %d Matrix =',N);disp(w8);  temp=zeros();for i=1:Nfor j=1:Ntemp=temp+(w8(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:Nfor j=1:Ntemp=temp+(w8(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:NY_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 w8w8=conj(w8);  disp('complex conjugate of w8');disp(w8);  y_m=zeros();temp=zeros();for i=1:Nfor j=1:Ntemp=temp+((1/N)*(w8(i,j)*Y_K(j)));end; y_m(i)=temp;temp=0;end;disp('y_m=');disp(y_m);  %plottingsubplot(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(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');`

Output: