MATLAB: Storing values for each iteration of a for loop

for loopstorevector

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

Best Answer

I just figured out my problem. I needed to reinitialize the variables of both trial[] and a=0 inside of the for loop.