How to draw multiple rectangular diffraction pattern
8 views (last 30 days)
Show older comments
Yi-Jing Pan
on 8 Dec 2019
Commented: Image Analyst
on 10 Dec 2019
I have a single rectangular diffraction pattern, and I want to draw 8*8 rectangular diffraction pattern.
I am relatively new at using matlab so any help would be much appreciated.
This is my single rectangular diffraction code:
clc
clear all
lambda=632e-9; k=(2*pi)/lambda;
a=1e-3; b=4e-3; d=20e-3;
Io = 100.0;
R = 1;
Y = (-0.4e-2:1e-5:0.4e-2); Z=Y ;
beta = k*b*Y/(2*R*pi);
alpha = k*a*Z/(2*R*pi);
for i=1:length(Y)
for j=1:length(Z)
I(i,j)=Io.*((sinc(alpha(j)).^2).*(sinc(beta(i))).^2);
end
end
figure(1)
imshow(I)
title('Fraunhofer Diffraction','fontsize',14)
fh = figure(1);
set(fh, 'color', 'white');
0 Comments
Accepted Answer
Image Analyst
on 8 Dec 2019
Simply use repmat(I, [8, 8]) to replicate your image 8 times in every direction.
lambda=632e-9;
k=(2*pi)/lambda;
a=1e-3;
b=4e-3;
d=20e-3;
Io = 100.0;
R = 1;
Y = (-0.4e-2 : 1e-5 : 0.4e-2);
Z=Y ;
beta = k*b*Y / (2*R*pi);
alpha = k*a*Z / (2*R*pi);
for i = 1 : length(Y)
for j = 1 : length(Z)
I(i, j) = Io .* ((sinc(alpha(j)).^2) .* (sinc(beta(i))).^2);
end
end
% Replicate in an 8-by-8 array
I8 = repmat(I, [8, 8]);
fh = figure;
imshow(I8, []);
title('Fraunhofer Diffraction', 'FontSize', 14)
set(fh, 'color', 'white');
axis('on', 'image');
2 Comments
Image Analyst
on 10 Dec 2019
Why do you say that? I simply used repmat() on your equation. Your equation is correct for the amplitude in the case of a single rectangular aperture. Using repmat() makes it correct for the case of an infinite rectangular grid of such rectangular apertures.
For an infinite pattern, the pattern would extend to inifinity. The image is an 8-by-8 section of that infinite pattern.
For a non-infinite grid of rectangular apertures you'd have to multiply it by the 2-D sinc function of the extent of the grid, which would give a modulated sinc pattern since it's a sinc times a sinc.
For the intensity, rather than the amplitude, you'd have to square the image since intensity is amplitude squared.
If you change the intensity range
imshow(I8, [0, 1.5]);
you'll see the individual patterns better than just scaling the display between min and max intensity which is what imshow(I8, []); does. See:
So, that's what I thought I learned while getting my Ph.D. in optics. Please explain why you say it's not a diffraction pattern -- maybe I'm wrong.
More Answers (1)
Stijn Haenen
on 8 Dec 2019
Somthing like this?
clc
clear all
lambda=632e-9; k=(2*pi)/lambda;
a=1e-3; b=4e-3; d=20e-3;
Io = 100.0;
R = 1;
Y = (-0.4e-2:1e-5:0.4e-2); Z=Y ;
beta = k*b*Y/(2*R*pi);
alpha = k*a*Z/(2*R*pi);
ypos_rectangle=(-0.7e-2:2e-3:0.7e-2);
zpos_rectangle=(-0.7e-2:2e-3:0.7e-2);
for i=1:length(Y)
for j=1:length(Z)
Phase=0;
for r_y=1:8
for r_z=1:8
Phase=Phase+((sinc(alpha(j)-ypos_rectangle(r_y))).*(sinc(beta(i)-zpos_rectangle(r_z))));
end
end
I(i,j)=Io.*Phase^2;
end
end
figure(1)
imshow(I)
title('Fraunhofer Diffraction','fontsize',14)
fh = figure(1);
set(fh, 'color', 'white');
2 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!