shiftdata

Transfer a designated matrix dimension to the lead position.

Syntax

[out, perm, shifts] = shiftdata(x)

[out, perm, shifts] = shiftdata(x, dim)

Inputs

x
The matrix on which to shift dimensions.
Type: double | complex
Dimension: vector | matrix
dim
The dimension to transfer to the leading position.
(default: the first non-singleton dimension.)
Type: integer
Dimension: scalar

Outputs

out
The shifted matrix.
perm
A permutation vector. Returns [] if the dimensions are merely shifted due to leading singleton dimensions.
shifts
The number of shifts for leading non-singleton dimensions. Returns [] when perm is non-empty.

Example

x = reshape([1:24],4,2,3);
[out, perm, shifts] = shiftdata(x, 2)
x =
slice(:, :, 1) =
[Matrix] 4 x 2
1  5
2  6
3  7
4  8

slice(:, :, 2) =
[Matrix] 4 x 2
 9  13
10  14
11  15
12  16

slice(:, :, 3) =
[Matrix] 4 x 2
17  21
18  22
19  23
20  24

out =
slice(:, :, 1) =
[Matrix] 2 x 4
1  2  3  4
5  6  7  8

slice(:, :, 2) =
[Matrix] 2 x 4
 9  10  11  12
13  14  15  16

slice(:, :, 3) =
[Matrix] 2 x 4
17  18  19  20
21  22  23  24
perm = [Matrix] 1 x 3
2  1  3
shifts = [Matrix] 0 x 0

Comments

shiftdata is typically used in combination with unshiftdata

to transfer some dimension to the leading position and then restore the orignal order later./p>