MATLAB: A Varying matrix name in loop

MATLABmatrixvariables

I have a loop running from i=1 to N where N is unkown and inputted by the user and the commands in the loop generates a matrix and i would like the first loop to give me matrix1 and the second loopd to give me matrix2 so the matrix name is changed based on the i value, but im not really sure how to go about this problem

Best Answer

N = 10;
matrix = cell(N,1) ;
for i = 1:N
matrix{i} = rand(3) ;
end
Trust me, there is no meaning in naming as matrix1, matrix2,........ rather you can use the above and call them by
matrix{1}
matrix{2}
This is called cell referencing. Read about cells.