Surely there is a simple answer to this:
Suppose $ R = [3\,1\,2] $ and $ A $ is any matrix with three rows.
$$ A = \begin{bmatrix} 2 & 4 \\ 5 &2 \\ 0 & 3 \\ \end{bmatrix} $$
Is there a way to create a new matrix, $ B $, whose rows are specified by entries of $ R $? In other words the first row of $ B $ is the third row of $ A $, the second row of $ B $ is the first row of $ A $, and the third row of $ B $ is the second row of $ A $.
I've tried B = A[[R, All]]
, which is analogous to what I'd do in Matlab, B=A(I,:)
.
Permute[A, InversePermutation@R]
orExtract[A, List /@ R]
. $\endgroup$ – Marius Ladegård Meyer Feb 7 '17 at 20:26A[[R]]
give what you want? $\endgroup$ – bill s Feb 7 '17 at 20:28