Group Abstract Group Abstract

Message Boards Message Boards

1
|
9.5K Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Wolfram Language equivalent to Matlab Rot90?

Posted 10 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 BY: Sander Huisman
Posted 10 years ago

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

POSTED BY: Paul Davidson

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

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 10 years ago

Also, have a look at Transpose and Reverse. Note that Mathematica represents matrices and tensors as list structures.

POSTED BY: David Keith

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

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