Calculate Reflectance and Plot R with Wavelength using MATLAB - Homework Help"

  • Thread starter Thread starter Patrice_HS
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

This discussion focuses on creating a MATLAB program to calculate reflectance (R) based on multiple layers with varying refractive indices and lengths. The user aims to replicate functionality similar to the Filmetrics reflectance calculator. The provided MATLAB code initializes wavelength values, gathers user input for the number of layers, and computes matrices for reflectance calculations. The discussion highlights the need for further clarification on the output and its alignment with expected results.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Knowledge of optical properties, specifically refractive index
  • Familiarity with matrix operations in MATLAB
  • Basic principles of reflectance and interference in multilayer systems
NEXT STEPS
  • Explore MATLAB's matrix manipulation functions for optimizing calculations
  • Research the physics of light reflection and transmission in multilayer films
  • Learn about MATLAB plotting functions to visualize reflectance versus wavelength
  • Investigate error handling in MATLAB to improve user input validation
USEFUL FOR

Students in optics or materials science, MATLAB programmers, and anyone involved in simulating optical properties of multilayer systems.

Patrice_HS
Messages
1
Reaction score
0

Homework Statement


i want to make MATLAB coding which is similar to this program.
--> http://www.filmetrics.com/reflectance-calculator

if i put n layers which is consists of each different n(refractive index), l(length),
then it will calculate M=M1*M2+M3...*Mn, and calculate R. and plot R with wavelength.

Homework Equations

The Attempt at a Solution


wl = 350*10^(-9):10^(-9):850*10^(-9);
ns = 1.5;
n0 = 1;
R = [0];
R_result=[1 1; 1 1];
M_result=[1 1; 1 1];
S_result=[1 1; 1 1];

p = input('How many layers do you want? ');

for k=1:p
n(1,k) = input('Enter refractive coefficient of layer');
l(1,k) = input('Enter length of layer');
for ws = 1:501
A(k,ws) = cos((2*pi)*l(1,k))/wl(1,ws);
B(k,ws) = (-i*sin((2*pi)*l(1,k))/wl(1,ws))/n(1,k);
C(k,ws) = -i*n(1,k)*sin((2*pi)*l(1,k))/wl(1,ws);
D(k,ws) = cos((2*pi)*l(1,k))/wl(1,ws);
end
end

%this is attemt to make...
for wt = 1:501
for ws_1=1:501

for k_1=1:p
M_result(:,:,ws_1) = [A(k_1,ws_1) B(k_1,ws_1) ; C(k_1,ws_1) D(k_1,ws_1)];

for ws_1 = 1:501
S_result(:,:,wt) = S_result(:,:,wt) * M_result(:,:,ws_1);
end

end
end
end
 

Attachments

  • 스크린샷 2015-11-14 오후 5.43.50.png
    스크린샷 2015-11-14 오후 5.43.50.png
    35.8 KB · Views: 549
  • 스크린샷 2015-11-14 오후 5.45.58.png
    스크린샷 2015-11-14 오후 5.45.58.png
    2.4 KB · Views: 504
  • 스크린샷 2015-11-14 오후 5.46.02.png
    스크린샷 2015-11-14 오후 5.46.02.png
    1.9 KB · Views: 510
  • 스크린샷 2015-11-14 오후 5.46.04.png
    스크린샷 2015-11-14 오후 5.46.04.png
    3.3 KB · Views: 544
  • 스크린샷 2015-11-14 오후 5.46.07.png
    스크린샷 2015-11-14 오후 5.46.07.png
    614 bytes · Views: 525
Physics news on Phys.org
tell us what the output is... is it different then desired?
If so how?
 

Similar threads

Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
4
Views
2K
Replies
13
Views
2K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K