Last active
February 3, 2020 04:44
-
-
Save MShirazAhmad/0baeac60a1a929fdf5d565b79f0b9da2 to your computer and use it in GitHub Desktop.
Reflection and Transmission of Light from Multilayer Films: MATLAB Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function norm = norm2unity(input) | |
| norm=(input-min(input))/(max(input)-min(input)) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment