I'm getting an unexpected error "Subscript indices must either be real positive integers or logicals." from the line 'trans_P0 = Transmit(T_0);' in the below simple code. T_0 has a value of 1007, if I pass 1007 to Transmit I get no error, but if I pass T_0 I do, which is really unusual as its just looking up an indices. Anyone know what's causing this? (the line 'trans_Art = Transmit(T_A);' give no error fyi).
Z_0 = 1.007;
Z_Total = 1.453;
mu = 0.75;
r = 0.001:0.001:4;
Transmit = exp(-r*mu);
T_0 = round(Z_0,3)*1000;
T_A = round(Z_Total,3)*1000;
trans_P0 = Transmit(T_0);
trans_Art = Transmit(T_A);

 採用された回答

madhan ravi
madhan ravi 2018 年 10 月 28 日
編集済み: madhan ravi 2018 年 10 月 28 日

0 投票

Z_0 = 1.007;
Z_Total = 1.453;
mu = 0.75;
r = 0.001:0.001:4;
Transmit = exp(-r*mu);
T_0 = round(Z_0,3)*1000;
T_A = round(Z_Total,3)*1000;
trans_P0 = Transmit(vpa(T_0));
trans_Art = Transmit(T_A);

3 件のコメント

madhan ravi
madhan ravi 2018 年 10 月 28 日
編集済み: madhan ravi 2018 年 10 月 28 日
The problem was simple as you mentioned , T_0 was 1007 but matlab recognises the value in scientific notation as 1.0070e+03 (which is a float value rather than an integer[whole number]) which is the same as 1007 that’s what caused the problem . You can try Transmit(1007) and Transmit(1.0070+e03) and everything will be clear for you.
aidan
aidan 2018 年 10 月 28 日
Great, thanks for your help, much appreciated!!
madhan ravi
madhan ravi 2018 年 10 月 28 日
Anytime :)

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2018 年 10 月 28 日

コメント済み:

2018 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by