DocumentationHelp Center
Inverse permute array dimensions
A = ipermute(B,dimorder)
example
A = ipermute(B,dimorder) rearranges the dimensions of an array B in the order specified by the vector dimorder such that B = permute(A,dimorder).
B
dimorder
B = permute(A,dimorder)
permute
collapse all
Create a 4-by-3-by-2 array B, and compute its inverse permutation according to the dimension order [3 1 2].
[3 1 2]
rng default B = rand(4,3,2)
B = B(:,:,1) = 0.8147 0.6324 0.9575 0.9058 0.0975 0.9649 0.1270 0.2785 0.1576 0.9134 0.5469 0.9706 B(:,:,2) = 0.9572 0.4218 0.6557 0.4854 0.9157 0.0357 0.8003 0.7922 0.8491 0.1419 0.9595 0.9340
A = ipermute(B,[3 1 2])
A = A(:,:,1) = 0.8147 0.9572 0.6324 0.4218 0.9575 0.6557 A(:,:,2) = 0.9058 0.4854 0.0975 0.9157 0.9649 0.0357 A(:,:,3) = 0.1270 0.8003 0.2785 0.7922 0.1576 0.8491 A(:,:,4) = 0.9134 0.1419 0.5469 0.9595 0.9706 0.9340
The inverse permutation A is the array such that, when you permute it using the same dimension order, the result is equal to the original array B.
A
C = permute(A,[3 1 2])
C = C(:,:,1) = 0.8147 0.6324 0.9575 0.9058 0.0975 0.9649 0.1270 0.2785 0.1576 0.9134 0.5469 0.9706 C(:,:,2) = 0.9572 0.4218 0.6557 0.4854 0.9157 0.0357 0.8003 0.7922 0.8491 0.1419 0.9595 0.9340
Input array, specified as a vector, matrix, or multidimensional array.
Dimension order, specified as a row vector with unique, positive integer elements representing the dimensions of the input array.
This function supports tall arrays with the limitation:
Permuting the tall dimension (dimension one) is not supported.
For more information, see Tall Arrays for Out-of-Memory Data.
Usage notes and limitations:
Does not support cell arrays for the first argument.
See Variable-Sizing Restrictions for Code Generation of Toolbox Functions (MATLAB Coder).
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
permute | reshape | shiftdim | transpose
reshape
shiftdim
transpose
A modified version of this example exists on your system. Do you want to open this version instead?
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office