Function Reference
— Function File: y = shiftdim (x, n)
— Function File: [y, ns] = shiftdim (x)

Shifts the dimension 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