[TOC]

permute

Rearranging dimensions

Usage

b = permute(a, order)

Examples

Input
a = [1 2 3;4 5 6];
permute(a,[2 1])
Output
ans = 
 1.0000   4.0000
 2.0000   5.0000
 3.0000   6.0000
Input
a = rand(3,4);
b = permute(a,[3 1 4 2 5]);
size(b)
ndims(b)
Output
ans = 
 1.0000   3.0000   1.0000   4.0000   1.0000

ans = 
 4.0000
Input
a = rand(3,4);
b = ipermute(a,[3 1 4 2 5]);
c = permute(b,[3 1 4 2 5]);

% a and c have the same sizes
size(a),size(c)

% a and c are the same matrices
a - c
Output
ans = 
 3.0000   4.0000

ans = 
 3.0000   4.0000   1.0000   1.0000   1.0000

ans = 
 0.0000   0.0000   0.0000   0.0000
 0.0000   0.0000   0.0000   0.0000
 0.0000   0.0000   0.0000   0.0000