MATLAB: How to store each roll from a for loop as a matrix

matrixmatrix array

I would like to store each roll from my for loop as a row in a matrix so I can refer to this matrix later. Also c may decrease later.
if true
% code
end
Number of rounds= input ('Rounds?:')
c=10
for f=1:1:Number of rounds
D_s=randi(10,1,c);
end

Best Answer

Do you need to generate random numbers by round, or can you generate them all at once? If you can do the latter, here's one solution:
NumRounds = round(input('Rounds? '));
if NumRounds < 1 %In case user puts a wrong input
error('NumRounds cannot be negative');
end
RollsPerRound = 10; %This was your c, but c had no meaning - hence RollsPerRound is used.
D_s = cell(NumRounds, 1); %Storing results in cell array, in case RollsPerRound changes
for j = 1:length(D_s)
D_s{j} = randi(10, 1, RollsPerRound);
end