ipermute
Inverse of permute: restores the original dimension order.
Category: Language Fundamentals > Matrices and Arrays
Syntax
A = ipermute(B, order)
Undoes B = permute(A, order).
Description
permute and ipermute use the same vector, so ipermute(permute(A, p), p) is always A. This matters for permutations that are not their own inverse, such as [3 1 2]: applying permute with the same vector again would not restore the array.
Input arguments
B- Array that was produced by
permute. order- The same permutation vector that was given to
permute.
Output arguments
A- Array with the dimension order before the permutation.
Example
A = ones(2, 3, 4);
p = [3 1 2];
B = permute(A, p);
size(B)
size(ipermute(B, p))
Output
ans = 1×3
4 2 3
ans = 1×3
2 3 4