shiftdim

Syntax

Description

B = shiftdim(A,n)
shifts the dimensions of an array A by n positions.
shiftdim shifts the dimensions to the left when n is
a positive integer and to the right when n is a negative integer. For
example, if A is a 2-by-3-by-4 array, then
shiftdim(A,2) returns a 4-by-2-by-3 array.

B = shiftdim(A) returns
an array with the same elements as A but with leading dimensions of
length 1 removed.

Input Arguments

A — Input arrayvector | matrix | multidimensional array

Input array, specified as a vector, matrix, or multidimensional array.

n — Number of positionsinteger

Number of dimension positions to shift, specified as an integer. When
n is positive, shiftdim shifts the dimensions to
the left, wrapping the leading dimensions to the end. When n is
negative, shiftdim shifts the dimensions to the right, padding
additional leading dimensions with length 1.

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.