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.
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]]
You can probably also use SparseArray or MapIndexed… There are many many ways of doing this, it just depends on what you feel most comfortable using… @* or /* or /@ or #…& might seem intimidating for some people…