フィルターのクリア

Help with a simple function

1 回表示 (過去 30 日間)
Guillermo Lopez
Guillermo Lopez 2012 年 1 月 25 日
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

採用された回答

the cyclist
the cyclist 2012 年 1 月 25 日
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 件のコメント
Guillermo Lopez
Guillermo Lopez 2012 年 1 月 25 日
didn't notice :) Thank you very much for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by