To create numbered variables from a for loop

조회 수: 4 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by