Storing values for each iteration of a for loop
9 views (last 30 days)
Show older comments
Ryan Callaghan
on 25 Sep 2020
Answered: Ryan Callaghan
on 26 Sep 2020
Hello,
How do I store values from each iteration of the for loop to make one vector with all the outputs of each iteration?
In my code, I want to store the value of x (size of matrix trial) for each iteration of the for loop. Thanks
a=0;%
b=10;
Trial=[ ];
Iterations=zeros(1,b);
for k = 1 :b
while a ~= 7
Int = randi([1 12],1,1);
a=num2str(Int);
a=str2double(a);
Trial=[Trial;a];
end
[x,y]= size(Trial);
Iterations(1,k)=x;
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!