Making a matrix in a for loop -


i working mathematica , got stuck on technicalities.

rvec[r_] := unitvector[length[r], randominteger[{1, length[r]}]] fvec[r_] := r - rvec[r] + rvec[r] vec[r_] := module[{s = fvec[r]}, if[count[s, -1] > 0, r, s]] loop[r_, n_] := for[i = 1; l = r, < n + 1, i++, l = vec[l]; print[l]] 

the idea have loop going randomly subtract 1 number 1 entry in set , add in next iteration, catch no entry can drop below zero. output set of outcomes put beneath each other.

having done know how put entire output in form of 1 matrix:

https://i.gyazo.com/a4ef70ba5670fd53003e0ac5ec1e434e.png

instead of having output that, have in matrix form, in having set of outputs placed in larger set containing sets elements. me, able manipulate , work entire output.

if need make matrix consequently adding vector vector, can this:

vector = {1, 2, 3, 4, 5}; matrix = {};   (* initialize matrix *) do[matrix = append[matrix, vector], 5];   (* construct matrix adding line line*) matrixform[matrix]   (* print matrix *) 

please tell me if didn't understanf youy problem properly.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -