I have a matrix of values I intend to use in my objective function. For a given arrangement of numbers, randperm(n), i would like to arrange both rows and columns according to this random arrangement. For example if:
randperm(8) =1 4 2 3 6 8 7 5
arrange both rows and columns of matrix A according to this arrangement.
A = [0 3 4 1 5 1 1 3;
3 0 3 4 1 1 5 2;
4 3 0 1 2 1 1 4;
1 4 1 0 5 1 1 4;
5 1 2 5 0 5 5 1;
1 1 1 1 5 0 5 2;
1 5 1 1 5 5 0 4;
3 2 4 4 1 2 4 0];
You can use randperm result directly:
order = randperm(8);
A = A(order, order);