The definition of a lot of variables

4 ビュー (過去 30 日間)
Andrea Cesaro
Andrea Cesaro 2023 年 5 月 7 日
コメント済み: Andrea Cesaro 2023 年 5 月 10 日
I had to define a lot of variables like these where the numbers represent the indexes of the variables in the range from 1 to 6 in my case:
I1xx = (m1/3)*(dy1^2 + dz1^2); %[kg*m^2]
I1yy = (m1/3)*(a1^2- a1*b1 + b1^2 + dz1^2); %[kg*m^2]
I1zz = (m1/3)*(a1^2- a1*b1 + b1^2 + dy1^2); %[kg*m^2]
I2xx = (m2/3)*(dy2^2 + dz2^2); %[kg*m^2]
I2yy = (m2/3)*(a2^2- a2*b2 + b2^2 + dz2^2); %[kg*m^2]
I2zz = (m2/3)*(a2^2- a2*b2 + b2^2 + dy2^2); %[kg*m^2]
The question is: exist a method like a for cycle or any other method that I can use to write all variables with their name in a simple way?

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 5 月 7 日
No.
You could do it in a way that is a bit messy.
However, we firmly recommend against such coding. Alternatives are discussed at
  1 件のコメント
Andrea Cesaro
Andrea Cesaro 2023 年 5 月 10 日
Thank you

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by