> lapply(1:2, function(x) t(A[rev(1:3),,x]))
[[1]]
     [,1] [,2] [,3]
[1,] "g"  "d"  "a"
[2,] "h"  "e"  "b"
[3,] "i"  "f"  "c"

[[2]]
     [,1] [,2] [,3]
[1,] "p"  "m"  "j"
[2,] "q"  "n"  "k"
[3,] "r"  "o"  "l"

>

Is this what you are looking for?  I hope this helps.

Chel Hee Lee

On 02/05/2015 03:17 PM, Karim Mezhoud wrote:
Dear aal,

Is there a way to rotate array or a cube of matrices by Y axis?


MatLab example:

A = cat(3,{'a' 'b' 'c';'d' 'e' 'f';'g' 'h' 'i'},{'j' 'k' 'l';'m' 'n'
'o';'p' 'q' 'r'})

A(:,:,1) =

     'a'    'b'    'c'
     'd'    'e'    'f'
     'g'    'h'    'i'


A(:,:,2) =

     'j'    'k'    'l'
     'm'    'n'    'o'
     'p'    'q'    'r'

Rotate the cell array by 270 degrees.

B = rot90(A,3)

B(:,:,1) =

     'g'    'd'    'a'
     'h'    'e'    'b'
     'i'    'f'    'c'


B(:,:,2) =

     'p'    'm'    'j'
     'q'    'n'    'k'
     'r'    'o'    'l'


karim

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to