I am trying to run a simple for loop to create a matrix that made up of 2n vectors of random numbers that all sum to 1. I have the proper code for making a singular vector, but am having issues with my for loop. The resulting matrix should be of size 2nx2n the loop is 2n long and the vectors are 2n long, so I don't understand why the sides are mismatched.
r = rand(1,2.*n); %2n random numbers that will make up the vectors in Pr = r/sum(r); %normalize the vector to 1thesum = sum(r); %check that the vector sums to 1for i = 1:2.*nP(i) = r./sum(r); %repeat random vectors 2.*n times to create the matrix of probabilitiesend