Group Abstract Group Abstract

Message Boards Message Boards

Wolfram Language equivalent to Matlab Rot90?

Posted 9 years ago

Does anyone know if there is there a wolfram equivalent for the Matlab command Rot90 ?

B = rot90(A) rotates array A counterclockwise by 90 degrees. For multidimensional arrays, rot90 rotates in the plane formed by the first and second dimensions.


B = rot90(A,k) rotates array A counterclockwise by k*90 degrees, where k is an integer.

POSTED BY: Paul Davidson
6 Replies
Posted 9 years ago

Thank you evryone for your comments but special thanks to Sander for such a simple solution.

POSTED BY: Paul Davidson
POSTED BY: Sander Huisman

As David said it is very easy to do so:

rotccw = Reverse@*Transpose; (* defines a function to do counterclockwise rotation *)
rotcw = Transpose@*Reverse;  (* and clockwise rotation *)

a = Partition[Range[16], 4];
MatrixForm[a]
MatrixForm[rotcw[a]]
MatrixForm[rotccw[a]]
POSTED BY: Sander Huisman
Posted 9 years ago
POSTED BY: David Keith

For Graphics look up Rotate, and for vectors look up RotationTransform or RotationMatrix.

This is not what the OP asks for. Rot90 'rotates' a matrix in 90 degree steps (http://fr.mathworks.com/help/matlab/ref/rot90.html). Not rotation like Rotate, RotationTransform, RotationMatrix.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard