I have a problem with the inverse fourier transform of a function that is supposed to be smooth, but practically it becomes saw-shaped. The function in Fourier domain is: f(m,n)=im(heavisede(m)+heaviside(-m))/(m^2+n^2). Applying the ifft2 to this function must result in a smooth function as F(x,y)=x/(x^2+y^2). However, doing this leads to a saw-shaped function in x-direction.
I would appreciate any suggestion in this regard
Here is the code:
clc
clear all
N=pow2(8);
Lx=0.01;
XX=linspace(-Lx,Lx,N);
[X,Y]=meshgrid(XX,XX);
dx=XX(2)-XX(1);
% the grid in fourier domain is chosen in such a way to avoid the
% singularity at the origin
mm=2*pi/N/dx*linspace(-N/2,N/2,N);
[m,n]=meshgrid(mm);
fmn= i *m.*(heaviside(m)+heaviside(-m))./(m.^2+n.^2);
% the numerical ifft2 of the spectrum
fxy=1/dx^2*fftshift(ifft2(ifftshift(fmn)));
% the analytical ifft2 of the spectrum
Fxy=X./(X.^2+Y.^2);
subplot(2,1,1)
mesh(X,Y,abs(fxy))
title('the output by ifft2')
subplot(2,1,2)
mesh(X,Y,abs(Fxy))
title('the expected (analytical) inverse transform')