Random rows in matrix so no element from the first column occur twice in a row
Mostrar comentarios más antiguos
Hi,
I have a matrix of x rows and 8 columns and need to random the rows so no element from the first column occur twice in a row.
It is a x times 8 double.
I know how to random the first coulumn but end up with a x times 1 array instad.
Thank you in advance
Respuesta aceptada
Más respuestas (1)
A = randi(100,5,8);
A
[~,randrow] = sort(rand(size(A,1),1));
RandA = A(randrow,:)
Categorías
Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!