To create numbered variables from a for loop

7 ビュー (過去 30 日間)
Marco
Marco 2012 年 11 月 21 日
コメント済み: Walter Roberson 2018 年 7 月 4 日
Hi,
Is there a way to generate numbered variables by a for loop ?
For example, if I have:
for i = 1:4
How can I generate the variables:
A_1
A_2
A_3
A_4
(named automatically by for loop)

採用された回答

bym
bym 2012 年 11 月 21 日
Don't
Please see this FAQ
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 7 月 4 日
Anant Mane comments to bym,
'Accepted Answer' is not an answer at all.
Walter Roberson
Walter Roberson 2018 年 7 月 4 日
Anant Mane:
Not creating numbered variables is the recommended approach from all of the main volunteers here, most of whom have extensive MATLAB experience.
The FAQ that bym linked to has explanations of why it is not a good idea, and gives several alternatives, and also gives a method of creating such variables for those who feel that they really must.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by