MATLAB: How to store output for different values of i’s

arraycell arraysmatricesmatrixmatrix manipulation

for i = 1:4
p1= [1,2;2,3]
end
How to store output for different values of i's so that I end up 4 matrices instead of one matrix.I mean i dont want it to overwrites the matrices in the previous step.I want 4 matrices to be stored at the end.

Best Answer

p=cell(1,4); % before loop
p{i}=... % inside loop