I constructed my code of the Angular Spectrum Method. However, as the distance between the object and the plane of interest increases, the diffraction pattern never disappears; there is still some sort of a diffraction pattern, and I am expecting that it disappears as distance increases.(adsbygoogle = window.adsbygoogle || []).push({});

Here is the code:

I think my error came from the calculation of the alpha and beta components. I just don't know where...Code (Matlab M):clear; clc;

layer = zeros(499, 499);

diameter = 100*10^(-6);

radius = diameter/2;

wavelength = 500*10^(-9);

altitude = 2*10^(-3);

img_width = 1*10^(-3);

img_length = 1*10^(-3);

lambda = wavelength; % wavelength (meters)

z = altitude; % altitude (meters)

k = 2*pi/lambda; % wavenumber

phy_x = img_width; % physical width (meters)

phy_y = img_length; % physical length (meters)

obj_size = size(layer);

% alpha and beta (wavenumber components)

dx = linspace(-phy_x/2, phy_x/2, obj_size(2));

dx = dx(1:length(dx));

dy = linspace(-phy_y/2, phy_y/2, obj_size(1));

dy = dy(1:length(dy));

for i = 1:obj_size(2);

for j = 1:obj_size(1)

if sqrt(dx(i)^2 + dy(j)^2) <= radius;

layer(j, i) = 1;

end;

end;

end;

U0 = fftshift(fft2(layer));

Fs_x = obj_size(2)/img_width;

Fs_y = obj_size(1)/img_length;

dx2 = Fs_x^(-1);

dy2 = Fs_y^(-1);

x2 = dx2*(0:(obj_size(2) - 1))';

y2 = dy2*(0:(obj_size(1) - 1))';

dFx = Fs_x/obj_size(2);

dFy = Fs_y/obj_size(1);

Fx = (-Fs_x/2:dFx:(Fs_x/2 - dFx));

Fy = (-Fs_y/2:dFy:(Fs_y/2 - dFy));

alpha = lambda.*Fx; beta = lambda.*Fy;

% gamma

gamma = zeros(length(beta), length(alpha));

for j = 1:length(beta);

for i = 1:length(alpha);

if (alpha(i)^2 + beta(j)^2) > 1;

gamma(j, i) = 0;

else

gamma(j, i) = sqrt(1 - alpha(i)^2 - beta(j)^2);

end;

end;

end;

U1 = ifft2(fftshift(fft2(layer)).*exp(1i*k.*gamma.*z));

I1 = (1/(16*pi)).*(U1.*conj(U1));

Thank you in advance.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Code of the Angular Spectrum Method

Loading...

Similar Threads - Code Angular Spectrum | Date |
---|---|

Matlab Coding angular spectrum of waves in a fluid | Yesterday at 7:30 AM |

Matlab MATLab: Not enough inputs for nlinfit | Nov 16, 2017 |

Matlab Help needed to fix a matlab code | Nov 8, 2017 |

Converting Simulink model to C code, integration | Nov 5, 2017 |

**Physics Forums - The Fusion of Science and Community**