Filter löschen
Filter löschen

Help with a simple function

1 Ansicht (letzte 30 Tage)
Guillermo Lopez
Guillermo Lopez am 25 Jan. 2012
Hello everybody: I am trying to write a simple function that involves an equation which is:
n2 = C1 + C2(λ^2)/((λ^2)-C3) + C4(λ^2)/((λ^2)-C5)
C1 = 1.28604141; C2 = 1.07044083; C3 = 1.00585997e-2; C4 = 1.10202242; C5 = 100
the variable should be lambda (λ) as with different values of lambda there would be different values of n. I would therefore like to assign everytime a different value for lambda and hence get the different n values associated to that lambda.
So, my question is quite simple. Could anyone give me a hint on how to start the function as the one I have created seems to have more errors than lines?
function n=nSiO2(lambda0)
lambda0=500;
C1=1.28604141;
C2=1.07044083;
C3=1.00585997e-2;
C4=1.10202242;
C5=100;
n= sqrt(C1 + C2*(lambda0^2)/((lambda0^2)-C3) + C4(lambda0^2)/((lambda0^2)-C5));
end

Akzeptierte Antwort

the cyclist
the cyclist am 25 Jan. 2012
You forgot the "*" after C4, so you were trying to access a variable, instead of multipling. Does this work better?
n= sqrt(C1 + C2*(lambda0^2)/((lambda0^2)-C3) + C4*(lambda0^2)/((lambda0^2)-C5));
  1 Kommentar
Guillermo Lopez
Guillermo Lopez am 25 Jan. 2012
didn't notice :) Thank you very much for your help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by