1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab help please...

  1. Nov 14, 2015 #1
    1. The problem statement, all variables and given/known data
    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.
    2. Relevant equations


    3. 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
     

    Attached Files:

  2. jcsd
  3. Nov 16, 2015 #2

    donpacino

    User Avatar
    Gold Member

    tell us what the output is.... is it different then desired?
    If so how?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Matlab help please...
Loading...