%Construct a matrix f that is similar to the function
f = zeros(30,30);
f(5:24,13:17) = 1;
imshow(f)
%Compute and visualize the 30-by-30 DFT of f with these commands
F = fft2(f);
F2 = log(abs(F));
imshow(F2,[-1 5]); 
colormap(jet); colorbar
%add zero padding to f when computing its DFT
F = fft2(f,256,256);
imshow(log(abs(F)),[-1 5]); colormap(jet); colorbar
%using the function fftshift, which swaps the quadrants of F 
%so that the zero-frequency coefficient is in the center.
F = fft2(f,256,256);F2 = fftshift(F);
imshow(log(abs(F2)),[-1 5]); colormap(jet); colorbar