Subscript indices must either be real positive integers or logicals

2 ビュー (過去 30 日間)
Jesse
Jesse 2012 年 7 月 24 日
Greetings all,
Well, I've never seen this error before, and I did try making my imaginary parts real - still didn't help.
Here's my code if you will (the relevant parts, all things not shown are previously defined):
D = [5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25];
skin_depth_seawater = sqrt(2/sigma_helo_seawater*u*omega);
F_1 = 1;
r = sqrt(eta^2+i*omega*sigma_helo_seawater*u);
V_1 = sqrt(r^2 + (2*i*sigma_helo_seawater/sigma_helo_seawater));
R(D,r) = real(V_1*F_1 - r)/(V_1*F_1 + r); %****
Now when I run the file, it gives me the "subscript indices must either be real positive integers or logicals" error at the line where I have **.
Can someone explain what I am doing wrong and where I need to correct it?
Thanks!

採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 24 日
r = sqrt(eta^2+i*omega*sigma_helo_seawater*u);
will almost never be a positive integer, but you try to use r as a subscript in the output of the assignment.
  3 件のコメント
Walter Roberson
Walter Roberson 2012 年 7 月 25 日
編集済み: Walter Roberson 2012 年 7 月 25 日
Your D contains only values that are purely integer-valued.
The "i*" in your expression suggests that r is likely the square root of an imaginary number, which will not be a real positive integer when you try to store into R(D,r)
The problem isn't in storing imaginary numbers: the problem is trying to use an imaginary number as a subscript.
Try using
R(D,:) = (V_1*F_1 - r)/(V_1*F_1 + r);
Jesse
Jesse 2012 年 7 月 25 日
Awesome! Thanks Walter!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by