I have a 2D Gaussian beam at its waist (where the phase is zero throughout the transverse plane). When I use fft2 to find the 2D spatial Fourier transform and plot the phase, I observe that there is a pi phase shift between any 2 adjacent data points. However, I don't observe this when I use for loops to calculate the Fourier transform instead of using fft2.
Is this due to phase wrapping? How do I overcome this?
Thanks.
Edit: I'm posting the code for the fft of a circular aperture, since the same results are observed, and because it is much simpler.
Nx = 200; Ny = Nx;
%creating coordinate grids
x = -Nx/2:Nx/2 - 1; y = -Ny/2:Ny/2 - 1;
[X,Y] = meshgrid(x,y);
r = 15; %radius of aperture
Eip = ((X.^2 + Y.^2 ) <= r^2); %aperture
figure;pcolor(abs(Eip));axis square; shading flat; colorbar;
figure;pcolor(angle(Eip));axis square; shading flat; colorbar;
Cip = fftshift(fft2(Eip)); %FFT
figure;pcolor(abs(Cip));axis square; shading flat; colorbar;
figure;pcolor(angle(Cip));axis square; shading flat; colorbar;