Array indices must be positive integers or logical values.

Hi! I am getting this error and I do not understand why.
This is the line that is producin the error. However, all variables in this line have been defined successfully, and none of them are arrays. I do have the final loop, but it uses positive integers. Any thoughts?
M_max = -R1(distg2-distr1)+G1(distg2-distg1);
M_min = 0;
M_m = (M_max + M_min)/2; % Median moment
M_a = (M_max - M_min)/2; % Alternating moment
s_m = M_m*(d/2)/I; % Sigma m
s_a = M_a*(d/2)/J; % Sigma a
sigma_m = zeros(3);
sigma_a = zeros(3);
for (i = 1:3)
sigma_m(i) = kt(i)*s_m; % von mises equivalent median stress
sigma_a(i) = kt(i)*s_m; % von mises equivalent alternating stress
end

 採用された回答

Walter Roberson
Walter Roberson 2020 年 10 月 23 日

0 投票

You forgot to put in the multiplication operator. MATLAB has no implied multiplication, not anywhere. A(B) is indexing or function invocation, never multiplication.

2 件のコメント

Stephen23
Stephen23 2020 年 10 月 23 日
Does any (commonly used) programming language have implied multiplication?
Walter Roberson
Walter Roberson 2020 年 10 月 23 日
In Maple, if a numeric constant appears before a non-numeric expression, then it will be multiplied, and non-numeric expressions separated by whitespace will be multiplied. So 3 x y is valid Maple but not x 3 y or 3 x 5 y

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by