A = magic(3);
B = ones(3);

% pad with zeros to 8x8

A(8,8) = 0;
B(8,8) = 0;

% Compute the two-dimensional DFT of A and B using fft2, 
% multiply the two DFTs together, 
% and compute the inverse two-dimensional DFT of the result using ifft2

 C = ifft2(fft2(A).*fft2(B));
 
C = C(1:5,1:5);
C = real(C);
C




 