3
$\begingroup$

How can I do the below process on a matrix in a straightforward way:

Firstly, change the rows with columns and secondly, arrange the columns of the matrix in a way that for a N*N matrix, the first column changes its position with the N'th column, the second column changes its position with the (N-1)'th and so on.

$\endgroup$
6
$\begingroup$

Reverse[matrix, 2] flips the columns; Reverse[matrix] flips the rows

M = {{a, b}, {c, d}};

Reverse[Transpose[M], 2]
(* {{c, a}, {d, b}} *)
$\endgroup$
  • 5
    $\begingroup$ Transpose @ Reverse @ M is another possibility $\endgroup$ – Carl Woll Jun 4 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.