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

  • Thread starter Patrice_HS
  • Start date
  • Tags
    Matlab
In summary, calculating reflectance and plotting R with wavelength using MATLAB involves using the built-in functions "spectralReflectance" and "plot" to generate a graph displaying the relationship between reflectance and wavelength. The steps include importing and organizing the data, calculating the reflectance values, and plotting the results with the appropriate labels and formatting. By following these steps, users can easily visualize the reflectance spectrum and gain a better understanding of the materials or substances being analyzed.
  • #1
Patrice_HS
1
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: 465
  • 스크린샷 2015-11-14 오후 5.45.58.png
    스크린샷 2015-11-14 오후 5.45.58.png
    2.4 KB · Views: 425
  • 스크린샷 2015-11-14 오후 5.46.02.png
    스크린샷 2015-11-14 오후 5.46.02.png
    1.9 KB · Views: 423
  • 스크린샷 2015-11-14 오후 5.46.04.png
    스크린샷 2015-11-14 오후 5.46.04.png
    3.3 KB · Views: 459
  • 스크린샷 2015-11-14 오후 5.46.07.png
    스크린샷 2015-11-14 오후 5.46.07.png
    614 bytes · Views: 439
Physics news on Phys.org
  • #2
tell us what the output is... is it different then desired?
If so how?
 

1. How do I import data into MATLAB?

To import data into MATLAB, you can use the load function to load a file or the importdata function to import data from a file or a URL. You can also use the readtable function to read data from a spreadsheet or the csvread function to read data from a CSV file.

2. How do I plot data in MATLAB?

To plot data in MATLAB, you can use the plot function. You can specify the x and y values as input arguments, or you can first create a vector or matrix containing the data and then pass it to the plot function. You can also add a title, labels, and customize the appearance of the plot using various optional arguments.

3. How do I solve equations in MATLAB?

To solve equations in MATLAB, you can use the solve function. You need to define the variables and equations in symbolic form using the sym function, and then pass them to the solve function. You can also use the fzero function to find the root of a single-variable equation or the fsolve function to solve a system of equations.

4. How can I create a function in MATLAB?

To create a function in MATLAB, you can use the function keyword followed by the name of the function and the input arguments in parentheses. Then, you need to write the function body and specify the output arguments using the return keyword. You can save the function in a separate file with the same name as the function, or you can define it in the same file as your main script.

5. How do I find the documentation for a specific function in MATLAB?

To find the documentation for a specific function in MATLAB, you can use the help function. Simply type help followed by the name of the function and press enter. Alternatively, you can also use the doc function to open the documentation in the Help browser, which allows you to search for functions and browse through the available documentation.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
961
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
1K
Back
Top