Rearrange dimensions of N-D array
B = permute(A,order)
B = permute(A,order) rearranges the dimensions of A so that they are in the order specified by the vector order. B has the same values of A but the order of the subscripts needed to access any particular element is rearranged as specified by order. All the elements of order must be unique, real, positive, integer values.
Given any matrix A, the statement
is the same as A.'.
A = [1 2; 3 4]; permute(A,[2 1]) ans = 1 3 2 4
The following code permutes a three-dimensional array:
X = rand(12,13,14); Y = permute(X,[2 3 1]); size(Y) ans = 13 14 12