This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


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. The resulting array B has the same values as 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.


collapse all

Create a 3-by-4-by-5 array and permute it so that the first and third dimensions are switched.

A = rand(3,4,5);
B = permute(A,[3 2 1]);
ans = 1×3

     5     4     3


permute and ipermute are a generalization of transpose (.') for multidimensional arrays.

Extended Capabilities

Introduced before R2006a