How to randomly moving rows of a matrix

2 Ansichten (letzte 30 Tage)
mr mo
mr mo am 2 Dez. 2017
Kommentiert: mr mo am 2 Dez. 2017
I have a hypothetical matrix named A, e.g.
A=[1 2 3
4 5 6
7 8 9
4 6 8
3 4 7
6 8 9
2 4 9
2 3 7
1 5 7
9 6 7];
I want to move the rows of A randomly to have a new matrix A with different arrange of rows.
How can I do that?
Thanks.

Akzeptierte Antwort

the cyclist
the cyclist am 2 Dez. 2017
randomOrder = randperm(size(A,1));
newA = A(randomOrder,:);

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by