Home

Introduction

Contents

Scripts

FeedBack

Date 06/09/2010
Script S5_2_11.m
Download Script S5_2_11.m
%==============================================
%A five-slit grating
%==============================================
%
%distance between the slits in mm
d=0.1;
%parameter ks
ks=2*pi/d;
%
%==================================================
%The Fourier synthesis of square wave of five slits
%==================================================
%
%N integer odd numbers are defined between 1 and 2N-1
N=4000;
i=linspace(0,N-1,N);
p=2*i+1;
% pmax=length(p)
%M values of x are defined between -d/2 and d/2
M=56;
x=linspace(-d/2,d/2,M);
%g(x) is calculated in each x(j) point using N
%harmonic waves in the Fourier synthesis
%(see Sec.5.2.1)
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*ks*x(j);
fatt2(p)=cos(arg2(p));
g(j)=g(j)+fatt1(p)*fatt2(p);
end
g(j)=0.5+g(j);
end
g;
%the array containing the Fourier synthesis for the five slits
g5=[g g g g g];
%corresponding abscissa x5 is defined
e1=2.5*d;
x5=linspace(-e1,e1,5*M);
plot(x5,g5,'ro-'),grid on
title('The Fourier synthesis of square wave of five slits')
figure
%
%==============================================
%The corresponding Fourier transform
%==============================================
%
%lambda in mm
lambda=0.5e-03;
%
%interval between -1.5° and 1.5° divided in NN parts
NN=1001
tetag=linspace(-1.5,1.5,NN);
teta=tetag*pi/180;
%parameter k
k=(2*pi/lambda)*sin(teta);
%the G transform of g in NN points
for j=1:NN
gamma=k(j)*x5;
coseno=cos(gamma);
y5=g5.*coseno;
G(j)=(1/pi)*trapz(x5,y5);
end
%relative value is used
maxG=max(G)
GG=G/maxG;
plot(tetag,GG,'bd-'),grid on
axis([-1.5 1.5 -0.2 1])
title('Fourier transform function of tetag')
figure
%corresponding relative intensity Ir
GGs=conj(GG);
Ir=GG.*GGs;
plot(tetag,Ir,'r-'),grid on
% axis([-650 650 -0.3 1])
title('Relative intensity function of tetag (using Fourier transform)')
figure
%
%==============================================
%Relative intensity
%using Fraunhofer formulae
%==============================================
%
%h is the width of each slit
h=d/2;
%calculus of the diffraction factor
alfa=(h/2)*k;
num1=sin(alfa);
num1q=num1.*num1;
alfa2=alfa.*alfa;
%avoiding the warning divide by zero
den1q=alfa2+(alfa2==0)*eps;
%Ir1 intensity due to the diffraction
Ir1=num1q./den1q;
%calculus of the interference factor
beta=(d/2)*k;
num2=sin(5*beta);
num2q=num2.*num2;
den2=5*sin(beta);
den22=den2.*den2;
%avoiding the warning divide by zero
den2q=den22+(den22==0)*eps;
%Ir2 intensity due to the interference
Ir2=num2q./den2q;
%effective relative intensity
IrF=Ir1.*Ir2;
plot(tetag,IrF,'r-'),grid on
% axis([-650 650 -0.3 1])
title('Relative intensity function of tetag (using Fraunhofer formulae)')
%==============================================
%
Top