Store results of for loop in 1D array?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a variable called 'age' which comes as a result of a while loop. The number for 'age' changes every time so I want to use a for loop to store 10,000 values of 'age' in a 1D array using a for loop. How do I do this?
댓글 수: 1
Jan
2013년 8월 6일
What does "the number of 'age' changes" mean? Is this the output of a function and you want to store e.g. vectors like [1 x 2] and [1 x 3] in the output?
답변 (1개)
Walter Roberson
2013년 8월 6일
편집: Walter Roberson
2013년 8월 6일
ages = zeros(10000, 1);
for K = 1 : 10000
%calculate age at this point
%then
ages(K) = age;
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!