Skip to Main Content Skip to Search
Product Documentation

permute - Rearrange dimensions of N-D array

Syntax

B = permute(A,order)

Description

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.

Tips

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

Examples

Given any matrix A, the statement

permute(A,[2 1]) 

is the same as A.'.

For example:

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

See Also

circshift | fliplr | flipud | ipermute | reshape | shiftdim

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS