Merge a variable name with a running index from a loop?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi there, I want to save data generated within a loop in a set of variables, whereas I want the variables to have the running index attached to it. How can I do that?
Example:
for i=1:10
result=i^2
variable1=result =>>!! here I want to define sth that makes matlab create a variable name variable+i
end
Many thanks in advance!
댓글 수: 0
답변 (1개)
Jan
2012년 5월 18일
Don't do this.
It is much nicer, easier, and more reliable to debug to use a cell instead:
a = cell(1, 10);
for i = 1:10;
a{i} = result;
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!