MATLAB Implementation of Fresnel Diffraction in MatLab

Click For Summary
The discussion focuses on simulating Fresnel Diffraction in MatLab using Fast Fourier Transform (FFT) syntax, but the user is struggling to achieve satisfactory diffraction patterns. The provided code includes Fourier Transform calculations for both the object and image planes, but lacks defined variables, which hinders execution. Participants suggest sharing a complete code snippet with all variable definitions for better troubleshooting. The conversation emphasizes the importance of having all necessary components in the code for effective simulation. Overall, clarity in code structure and variable definitions is crucial for successful implementation of Fresnel Diffraction in MatLab.
ecastro
Messages
249
Reaction score
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).
 
Physics news on Phys.org
I recommend posting a code snippet that can run. The first thing I tried to do was run the code you posted, and then I realized none of the variables are defined. I'm sure you have them defined in your script, so just post them here as well so that the code can be copy/pasted to run.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
11K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
13K
  • · Replies 2 ·
Replies
2
Views
20K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 14 ·
Replies
14
Views
6K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K