Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MShirazAhmad authored Dec 7, 2018
1 parent 465fe4f commit 953dfde
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Matrix.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function m = Matrix(Phi,Z)
Limit=length(Phi);
M1=[1 0;0 1];
for j=2:Limit
M{j} = [cosd(Phi(j)) (1i*sind(Phi(j)))/Z(j) ; 1i*Z(j)*sind(Phi(j)) cosd(Phi(j))];
M1=M1*M{j};
end
m=M1;
end
18 changes: 18 additions & 0 deletions MultiLayerFilm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function [Incident,RS,RP,TS,TP] = MultiLayerFilm(n,d,Incident,Lambda)
BOUNDRY = length(n)-1;
INC=Incident;
for INCIDENCE=Incident
%% Calculation of angles on boundries starting from first
Theta=SnellsLaw(n,INCIDENCE);
%%
Phi(2:BOUNDRY) = n(2:BOUNDRY).*d(1:BOUNDRY-1).*(2.*pi./(Lambda));
Z_s = (2.6544e-3).*n(1:BOUNDRY+1).*cosd(Theta(1:BOUNDRY+1));
Z_p = (2.6544e-3).*n(1:BOUNDRY+1)./cosd(Theta(1:BOUNDRY+1));
m1=Matrix(Phi,Z_s);
[R_s(INCIDENCE+1),T_s(INCIDENCE+1)]=R_T(m1,Z_s(1),Z_s(BOUNDRY+1));
m2=Matrix(Phi,Z_p);
[R_p(INCIDENCE+1),T_p(INCIDENCE+1)]=R_T(m2,Z_p(1),Z_p(BOUNDRY+1));
end
RS=R_s;,RP=R_p;,TS=T_s;,TP=T_p;
rtplot(Incident,R_s,R_p,T_s,T_p);
end
8 changes: 8 additions & 0 deletions R_T.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function [R,T] = R_T(m,Z_o,Z_s)
r=(Z_o*m(1,1)+Z_o*Z_s*m(1,2)-m(2,1)-Z_s*m(2,2))/...
(Z_o*m(1,1)+Z_o*Z_s*m(1,2)+m(2,1)+Z_s*m(2,2));
t=(2*Z_o)/...
(Z_o*m(1,1)+Z_o*Z_s*m(1,2)+m(2,1)+Z_s*m(2,2));
T=abs(t.*t');
R=abs(r.*r');
end
8 changes: 8 additions & 0 deletions SnellsLaw.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function angles = SnellsLaw(n, incident)
Theta=zeros(1,length(n));
Theta(1)=incident;
for j=2:length(n)
Theta(j) = asind((n(j-1)/n(j))*sind(Theta(j-1)));
end
angles=Theta;
end
3 changes: 3 additions & 0 deletions norm2unity.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function norm = norm2unity(input)
norm=(input-min(input))/(max(input)-min(input))
end
13 changes: 13 additions & 0 deletions rtplot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Output = rtplot(Incident,R_s,R_p,T_s,T_p)
Incident=Incident+1;
plot(Incident,T_s,'r');
hold on
plot(Incident,R_s,'r');
hold on
plot(Incident,T_p,'b');
plot(Incident,abs(R_p),'b');
hold off
%[K,I] = min(R_p);
%X_b=I.*(ones(1,length(Incident)));
%plot(X_b,R_p,'--');
end

0 comments on commit 953dfde

Please # to comment.