Navigation

Operators and Keywords

Function List:

C++ API

: y = shiftdim (x, n)
: [y, ns] = shiftdim (x)

Shift the dimensions of x by n, where n must be an integer scalar.

When n is positive, the dimensions of x are shifted to the left, with the leading dimensions circulated to the end. If n is negative, then the dimensions of x are shifted to the right, with n leading singleton dimensions added.

Called with a single argument, shiftdim, removes the leading singleton dimensions, returning the number of dimensions removed in the second output argument ns.

For example:

x = ones (1, 2, 3);
size (shiftdim (x, -1))
   ⇒ [1, 1, 2, 3]
size (shiftdim (x, 1))
   ⇒ [2, 3]
[b, ns] = shiftdim (x)
   ⇒ b = [1, 1, 1; 1, 1, 1]
   ⇒ ns = 1

See also: reshape, permute, ipermute, circshift, squeeze.

Package: octave