Home

Introduction

Contents

Scripts

FeedBack

Date 08/09/2010
Script S1_2_14.m
Download Script S1_2_14.m
%==============================================
%refraction through a transparent plate whose
%refractive index is a linear function od the
%thickness h
%==============================================
%
%thickness h in cm
h=1;
%refractive index and h are divided in N parts
N=100;
%the first and the last term of refractive index
n1=1.45;
n2=2.50;
%value z of a part of h (called deltah in the book)
z=h/N;
%the range of refractive indexes
n=linspace(n1,n2,N);
%the angle on incidence in degrees between 0 and 60
alfag=eps:2:60
%the number of angles
maxj=length(alfag);
%
%================================================
%the external loop varying alfag
%================================================
%
for j=1:maxj
alfa=alfag(j)*pi/180;
arg(1)=sin(alfa)/n(1);
beta(1)=asin(arg(1));
%the first shift x
x(1)=z*tan(beta(1));
h=x(1);
%the first length b
b(1)=z/cos(beta(1));
arg1(1)=alfa-beta(1);
%the first distance d
d=b(1)*sin(arg1(1));
%
%==================================
%the inner loop over the N slots
%==================================
%
for i=2:N
arg(i)=n(i-1)*sin(beta(i-1))/n(i);
beta(i)=asin(arg(i));
%next shift x
x(i)=z*tan(beta(i));
h=h+x(i);
%next length b
b(i)=z/cos(beta(i));
arg1(i)=beta(i-1)-beta(i);
%next distance d
d=d+b(i)*sin(arg1(i));
end
%
%==================================
%end of the inner loop
%==================================
%
%an element is added to the array H
H(j)=h;
%and to the array D
D(j)=d;
end
%
%================================================
%end of the external loop
%================================================
%
%the array H contains vertical partial shifts xi, in cm,
%varying the angle of incidence
H;
%the array D contains partial distances di, in cm,
%varying the angle of incidence
D;
%
%================================================
%
%================================================
%
%the refractive index is fixed
An=1.45;
%the thickness of the plate in cm
Ah=1;
%the angle of incidence varying from 0 to 60°
Aalfag=eps:2:60;
%the angles in radians
Aalfa=Aalfag*pi/180
%the refraction angle
Aarg=sin(Aalfa)/An;
Abeta=(asin(Aarg));
%===============================================================
%we check that the emerging angle is equal to the incident angle
Atest=asin(An*sin(Abeta))
%===============================================================
%the vertical shift Ax in cm varying the angle of incidence
Ax=Ah*tan(Abeta)
Ab=Ah./cos(Abeta);
Aarg1=Aalfa-Abeta;
%the distance Ad between the incident and the emerging rays
Ad=Ab.*sin(Aarg1)
%
%==========================================================================
%plot of vertical shift with n variable and constant
%==========================================================================

plot(alfag,H,'bd-',Aalfag,Ax,'ro-'),grid on,
title('blue for n variabile and red for n constant'),
xlabel('angle of incidence in degree')
ylabel('vertical shifts in cm')
% axis([0 90 0 1]
figure
%
%==========================================================================
%plot of the distance between the incident and the emerging rays
%with n variable and constant
%==========================================================================
subplot(2,1,1)
plot(alfag,D,'bd-'),grid on, title('the distance for n variable varying alfa'),
% axis([0 90 0 1]
subplot(2,1,2)
plot(Aalfag,Ad,'ro-'),grid on, title('the distance for n constant varying alfa')
% axis([0 90 0 1]
%==========================================================================
%
Top