For loop indexing error
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
ri = 40.34;
rf = 40;
Em = 3.5e-9;
Ef = 1000e-9;
z = linspace(0,0.34,12);
n=1;
E = zeros(12);
r = zeros(12);
for j = 1:12
r(j)= z(j)+40;
E(j) = Em*(ri/r(j))+(((ri-r(j))/(ri-rf))^(n/2))*(Ef-Em(ri/rf));
end
I'm getting this error
Array indices must be positive
integers or logical values.
Error in interface_modulus
(line 11)
E(j) =
Em*(ri/r(j))+(((ri-r(j))/(ri-rf))^(n/2))*(Ef-Em(ri/rf));
0 件のコメント
回答 (1 件)
ri = 40.34;
rf = 40;
Em = 3.5e-9;
Ef = 1000e-9;
z = linspace(0,0.34,12);
n=1;
E = zeros(12);
r = zeros(12);
for j = 1:12
r(j)= z(j)+40;
E(j) = Em*(ri/r(j))+(((ri-r(j))/(ri-rf))^(n/2))*(Ef-Em*(ri/rf));
end
Type error:
Replaced
Em(ri/rf)
with
Em*(ri/rf)
When you try Em(ri/rf), it will take as index..and the value comes to be fraction. The indices cannot be fraction..so error.
0 件のコメント
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!