permute
Generalized transpose of a matrix, using a permutation vector.
Syntax
permute(A, P)
Inputs
- A
- Type: double | integer | char | string | logical | struct | cell
- P
- Type: integer
Outputs
- R
- The pemuted matrix.
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=permute(m, [2,3,1])
p =
slice(:, :, 1) =
[Matrix] 4 x 5
111 112 113 114 115
121 122 123 124 125
131 132 133 134 135
141 142 143 144 145
slice(:, :, 2) =
[Matrix] 4 x 5
211 212 213 214 215
221 222 223 224 225
231 232 233 234 235
241 242 243 244 245
slice(:, :, 3) =
[Matrix] 4 x 5
311 312 313 314 315
321 322 323 324 325
331 332 333 334 335
341 342 343 344 345
Comments
The vector P must contain all explicit dimensions of A, and may also contain implicit higher singleton dimensions.