Array index error help

1 回表示 (過去 30 日間)
Scott Hunter
Scott Hunter 2018 年 11 月 24 日
コメント済み: Scott Hunter 2018 年 11 月 25 日
Can anyone explain to me why I'm geeting an array indexing error for this script?
Array indices must be positive integers or logical values.
"Error in Finding_rp_test (line 32)
rn = (An(1-(En^2)))./(1+En*cos(thn));"
It's in the last line where I assign rn (Intending on running this for an array of 't' not just a single value).
An = 178942976.896420
En = 0.1781
t = 1
Mn = Nn*t;
EE0n = Mn;
DEEn = ((Mn-EE0n)+En*sin(EE0n))./(1-En*cos(EE0n));
if En==0
thn = Mn;
else
while DEEn>10^-12
DEEn = (Mn-EE0n+(En*sin(EE0n)))./(1-(En*cos(EE0n)));
EE0n = EE0n + DEEn;
thn = 2*atan((((1+En)./(1-En))^0.5)*tan(EE0n./2));
end
end
rn = (An(1-(En^2)))./(1+En*cos(thn));

採用された回答

Image Analyst
Image Analyst 2018 年 11 月 24 日
An is a scalar, not an array, so perhaps you meant:
rn = (An*(1-(En^2)))./(1+En*cos(thn));
  1 件のコメント
Scott Hunter
Scott Hunter 2018 年 11 月 25 日
Wow, massive facepalm. Been looking at it for days, all just a typo! Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by