Effacer les filtres
Effacer les filtres

Help with a simple function

1 vue (au cours des 30 derniers jours)
Guillermo Lopez
Guillermo Lopez le 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by