FUNCTION REFERENCE

shiftdim

Shift array dimensions or remove leading singleton dimensions.

Shift array dimensions or remove leading singleton dimensions.

Syntax

shiftdim(A); shiftdim(A, N); [B, N] = shiftdim(A)

Without N, a row becomes a column and N reports the number of removed leading singleton dimensions. Positive N rotates dimensions; negative N adds leading singleton dimensions. Results must fit in two dimensions.

Example

shiftdim([1 2; 3 4], 1)   % [1 3; 2 4]

Example

size(shiftdim(ones(2,3,4),1))   % [3 4 2]

Differences from MATLAB: Numeric, logical, char and complex input; a positive n shifts by mod(n, ndims(A)) and a negative n prepends singleton dimensions.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.