![]() |
||||||
|
| Script S5_2_1A.m | |||
|
|||
|
%==============================================
%Single slit A %diffraction of a single slit using Fourier %functions %============================================== % %distance d in mm; d/2 is the aperture of the slit d=0.1; %the k value k=2*pi/d; % %============================================== %Fourier series expansion %of the the top-hat function %============================================== % %p integer odd numbers between 1 and 2N-1 %are defined N=4000; i=linspace(0,N-1,N); % imax=i(end) p=2*i+1; % pmax=p(end) %interval between -d/2 and d/2 is divided in M parts %defining the array x M=56; x=linspace(-d/2,d/2,M); %g(x) is defined for each of M x(j) %using N addends of the Fourier series expansion for j=1:M g(j)=0; for p=1:N arg1(p)=p*(pi/2); fatt1(p)=sin(arg1(p))/arg1(p); arg2(p)=p*k*x(j); fatt2(p)=cos(arg2(p)); g(j)=g(j)+fatt1(p)*fatt2(p); end g(j)=0.5+g(j); end g; plot(x,g,'ro-'),grid on title('The "top-hat" function varying x between -d/2 and d/2 (in mm)') figure % %============================================== %its Fourier transform %============================================== % %only the second and third quarter of the arrays x and g %are considered ia=M/4+1 ib=(M/4)*3 %the corresponding x now called xx xx=x(ia:ib); %the corresponding g now called gg gg=g(ia:ib); % %NN is the length of the array t used to define the %Fourier transform G NN=101 %lambda in mm lambda=0.5e-03; %angular interval between -3° and 3° divided in NN parts tetag=linspace(-3,3,NN); %corresponding values in radians teta=tetag*pi/180; %the variable t is defined t=(2*pi/lambda)*sin(teta); %the Fourier transform G of g is calculated in NN points for ii=1:NN gamma=t(ii)*xx; coseno=cos(gamma); yy=gg.*coseno; G(ii)=(1/pi)*trapz(xx,yy); end %its relative value GG is assumed for the plot maxG=max(G) GG=G/maxG; plot(t,GG,'bd-'),grid on,axis([-650 650 -0.3 1]) title('The Fourier transform GG varying t (function of teta)') figure plot(tetag,GG,'g*-'),grid on axis([-3 3 -0.3 1]) title('The Fourier transform GG varying tetag') %============================================== % |
|||
| Top | |||
| Script S5_2_1B.m | |||
|
|||
|
%==============================================
%Single slit B %diffraction of a single slit using classical %calculation %============================================== % %d (see "Single slit A") d=0.05; %lambda (see "Single slit A") lambda=0.5e-03; %k is defined k=2*pi/lambda; %interval of angular positions between 3° and -3° %divided into NN parts NN=101 tetag=linspace(-3,3,NN); %coresponding values in radians teta=tetag*pi/180; %the parameter t=k*sin(teta) t=k*sin(teta); %argument alfa of the function sin(alfa)/alfa %if equal to zero is replaced by the MATLAB value "eps" alfa=0.5*d*t+(0.5*d*t==0)*eps; %the sinc(alfa) function sinc=sin(alfa)./alfa; plot(t,sinc,'ro-'),grid on,axis([-600 600 -0.3 1]), title('The sinc function varying t') figure plot(tetag,sinc,'bd-'),grid on axis([-3 3 -0.3 1]), title('The sinc function varying tetag') figure % sincq=sinc.^2; plot(t,sincq,'ro-'),grid on axis([-600 600 0 1]), title('The sincq, or relative intensity, function varying t') figure plot(tetag,sincq,'bd-'),grid on axis([-3 3 0 1]), title('The sincq, or relative intensity, function varying tetag') %============================================== % |
|||
| Top | |||