- #1
ecastro
- 254
- 8
I'm trying to simulate the Fresnel Diffraction in MatLab using the Fast Fourier Transform syntax. But I'm not getting really good diffraction patterns. Here is the code:
%% Fourier Transform for G(p, q)
g = layer.*exp(((1i*pi)/(lambda*z))*(r_obj));
G = fftshift(fft2(g));
%% Fourier Transform for H(p, q)
h = (exp(1i*k*z)/(1i*lambda*z))*exp(((1i*k)/(2*z))*(r_img));
H = fftshift(fft2(h));
U = fftshift(ifft2(H.*G));
And these are the value for r_obj and r_img:
r_obj = ones(size(layer));
r_img = ones(size(layer));
for j = 1: obj_size(2);
for i = 1: obj_size(1);
r_obj(i, j) = x_prime(i)^2 + y_prime(j)^2;
r_img(i, j) = x(i)^2 + y(j)^2;
end;
end;
I don't know what's wrong with my code (or with my equations).
%% Fourier Transform for G(p, q)
g = layer.*exp(((1i*pi)/(lambda*z))*(r_obj));
G = fftshift(fft2(g));
%% Fourier Transform for H(p, q)
h = (exp(1i*k*z)/(1i*lambda*z))*exp(((1i*k)/(2*z))*(r_img));
H = fftshift(fft2(h));
U = fftshift(ifft2(H.*G));
And these are the value for r_obj and r_img:
r_obj = ones(size(layer));
r_img = ones(size(layer));
for j = 1: obj_size(2);
for i = 1: obj_size(1);
r_obj(i, j) = x_prime(i)^2 + y_prime(j)^2;
r_img(i, j) = x(i)^2 + y(j)^2;
end;
end;
I don't know what's wrong with my code (or with my equations).