permute
Rearrange dimensions of an N-D array.
Syntax
Section titled “Syntax”B = permute(A, order)Description
Section titled “Description”Returns A with its dimensions permuted according to order. order is a vector containing the integers 1 through ndims(A), each appearing exactly once. permute(A, [2 1]) is the transpose for 2D matrices; permute(A, [3 1 2]) cycles the dimensions of a 3D array.
Examples
Section titled “Examples”A = reshape(1:24, [2 3 4]);B = permute(A, [3 2 1]); % size [4 3 2]ipermute(B, [3 2 1]) % round-trip back to A