![]() |
||||||
|
| Script S5_2_19A.m | |||
|
|||
|
%===================================================
%Fraunhofer and Fresnel diffraction of a single-slit % %Part A1: Fraunhofer diffraction using Fresnel integral %b=1000 - hmax=10 - tmax=0.1 (all values in mm) %=================================================== % %lambda in mm lambda=5e-4; %distance b between A-B and A'-B' in mm b=1000; %y is defined in the interval (-hmax, hmax) with a step dy %hmax and dy in mm hmax=10; dy=0.1; y=-hmax:dy:hmax; Ly=length(y) %t is defined in the interval (-tmax, tmax) with a step dt %tmax and dt in mm tmax=0.1; dt=0.01; t=-tmax:dt:tmax; Lt=length(t) %a costant cost=pi/(lambda*b); %loop over the y for i=1:Ly y1=y(i); arg1=(y1-t).^2; arg2=1i*cost*arg1; f=exp(arg2); E=trapz(t,f); Es=conj(E); Int(i)=E*Es; end Int; LI=length(Int) %relative intensity Ir Intmax=max(Int); Ir=Int/Intmax; %=================================================== % %full plot plot(y,Ir,'ro-') title('Fraunhofer diffraction using Fresnel integral and y in abscissa') figure %partial plot plot(y,Ir,'ro-') title('Magnification of the lower values of the previous plot') axis([-10 10 0 0.1]) %=================================================== % |
|||
| Top | |||
| Script S5_2_19B.m | |||
|
|||
|
%================================================
%Fraunhofer Fresnel diffraction for a single-slit % %Part A2: Fraunhofer diffractio using Fraunhofer %formula with the same lambda and geometrical %values of the previous script %================================================ % %distance d = 2tmax (tmax = 0.1 in previous script) d=0.2; ymax=100 %distance b between A-B and A'-B' in mm b=1000; %lambda in mm lambda=0.5e-03; %parameter k k=2*pi/lambda; %NN angular positions corresponding %to the previous vertical position y on the screen NN=1001 tetamax=(atan(ymax/b))*180/pi tetag=linspace(-tetamax,tetamax,NN); teta=tetag*pi/180; %the array t t=k*sin(teta); %alfa is set equal to eps if it is zero alfa=0.5*d*t+(0.5*d*t==0)*eps; %the standard sinc(alfa) function sinc=sin(alfa)./alfa; %its square sincq=sinc.^2; %plot plot(tetag,sincq,'ro-') axis([-0.6 0.6 0 1]), title('Fraunhofer diffraction using Fraunhofer formula and tetag in abscissa') %================================================ % |
|||
| Top | |||
| Script S5_2_19C.m | |||
|
|||
|
%===================================================
%Fraunhofer and Fresnel diffraction of a single-slit % %Part B1: Fresnel diffraction using Fresnel integral %b=1000 - hmax=10 - tmax=1 (all values in mm) %=================================================== % %lambda in mm lambda=5e-4; %distance b between A-B and A'-B' in mm b=1000; %y is defined in the interval (-hmax, hmax) with a step dy %hmax and dy in mm hmax=10; dy=0.1; y=-hmax:dy:hmax; Ly=length(y) %t is defined in the interval (-tmax, tmax) with a step dt %tmax and dt in mm tmax=1; dt=0.01; t=-tmax:dt:tmax; Lt=length(t) %a costant cost=pi/(lambda*b); %loop over the y for i=1:Ly y1=y(i); arg1=(y1-t).^2; arg2=1i*cost*arg1; f=exp(arg2); E=trapz(t,f); Es=conj(E); Int(i)=E*Es; end Int; LI=length(Int) %relative intensity Ir Intmax=max(Int); Ir=Int/Intmax; %=================================================== % %full plot plot(y,Ir,'ro-') title('Fresnel diffraction using Fresnel integral with y in abscissa') figure %partial plot plot(y,Ir,'ro-') title('Magnification of the lower values of the previous plot') axis([-10 10 0 0.1]) %=================================================== % |
|||
| Top | |||
| Script S5_2_19D.m | |||
|
|||
|
%===================================================
%Fraunhofer and Fresnel diffraction of a single-slit % %Part B2: Fresnel diffraction using Fresnel integral %b=1000 - hmax=10 - tmax=2 (all values in mm) %=================================================== % %lambda in mm lambda=5e-4; %distance b between A-B and A'-B' in mm b=1000; %y is defined in the interval (-hmax, hmax) with a step dy %hmax and dy in mm hmax=10; dy=0.1; y=-hmax:dy:hmax; Ly=length(y) %t is defined in the interval (-tmax, tmax) with a step dt %tmax and dt in mm tmax=2; dt=0.01; t=-tmax:dt:tmax; Lt=length(t) %a costant cost=pi/(lambda*b); %loop over the y for i=1:Ly y1=y(i); arg1=(y1-t).^2; arg2=1i*cost*arg1; f=exp(arg2); E=trapz(t,f); Es=conj(E); Int(i)=E*Es; end Int; LI=length(Int) %relative intensity Ir Intmax=max(Int); Ir=Int/Intmax; %=================================================== % %full plot plot(y,Ir,'ro-') title('Fresnel diffraction using Fresnel integral with y in abscissa') figure %partial plot plot(y,Ir,'ro-') title('Magnification of the lower values of the previous plot') axis([-10 10 0 0.1]) %=================================================== % |
|||
| Top | |||