Azzera filtri
Azzera filtri

Help with a simple function

1 visualizzazione (ultimi 30 giorni)
Guillermo Lopez
Guillermo Lopez il 25 Gen 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

Risposta accettata

the cyclist
the cyclist il 25 Gen 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 Commento
Guillermo Lopez
Guillermo Lopez il 25 Gen 2012
didn't notice :) Thank you very much for your help.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by