ipermute

Generalized reversing transpose of a matrix, using a permutation vector.

Syntax

ipermute(A, P)

Inputs

A
Type: double | integer | char | string | log
Dimension: scalar | vector | matrix
P
Type: integer
Dimension: vector

Outputs

R
The permuted input.

Example

m(:,:,1) = [111, 121, 131, 141; 211, 221, 231, 241; 311, 321, 331, 341];
m(:,:,2) = [112, 122, 132, 142; 212, 222, 232, 242; 312, 322, 332, 342];
m(:,:,3) = [113, 123, 133, 143; 213, 223, 233, 243; 313, 323, 333, 343];
m(:,:,4) = [114, 124, 134, 144; 214, 224, 234, 244; 314, 324, 334, 344];
m(:,:,5) = [115, 125, 135, 145; 215, 225, 235, 245; 315, 325, 335, 345];
p = ipermute(m, [2,3,1])
p =
slice(:, :, 1) =
[Matrix] 5 x 3
111  211  311
112  212  312
113  213  313
114  214  314
115  215  315

slice(:, :, 2) =
[Matrix] 5 x 3
121  221  321
122  222  322
123  223  323
124  224  324
125  225  325

slice(:, :, 3) =
[Matrix] 5 x 3
131  231  331
132  232  332
133  233  333
134  234  334
135  235  335

slice(:, :, 4) =
[Matrix] 5 x 3
141  241  341
142  242  342
143  243  343
144  244  344
145  245  345

Comments

The vector P must contain all explicit dimensions of A, and may also contain implicit higher singleton dimensions.

ipermute reverses the effect of permute when called with the same P.