Store results of for loop in 1D array?
4 次查看(过去 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!