I wrote a short matlab script file that would suggest running Fresnel propagation (diffraction), so for a given input field U0, it will tell you how the field looks after distance z0. I compared the result with the results of textbooks, and it seems that my program works fine. The problem is that I am trying to complete two distribution steps instead of one. that is, instead of one iteration of the program for spreading the distance z0, I take two iterations of the program for spreading the distance z0 / 2 each. Then I get complete nonsense, and I cannot understand what the problem is. Any advice would be greatly appreciated. Here is the code:
function U = fresnel_advance (U0, dx, dy, z, lambda)
% The function receives a field U0 at wavelength lambda
% and returns the field U after distance z, using the Fresnel
% approximation. dx, dy, are spatial resolution.
k=2*pi/lambda;
[ny, nx] = size(U0);
Lx = dx * nx;
Ly = dy * ny;
dfx = 1./Lx;
dfy = 1./Ly;
u = ones(nx,1)*((1:nx)-nx/2)*dfx;
v = ((1:ny)-ny/2)'*ones(1,ny)*dfy;
O = fftshift(fft2(U0));
H = exp(1i*k*z).*exp(-1i*pi*lambda*z*(u.^2+v.^2));
U = ifft2(O.*H);
source
share