Shifts the dimensions of a multi-dimensional array.
b = shiftdim(x)
b = shiftdim(x,n)
[b,nshifts] = shiftdim(x)
[b,nshifts] = shiftdim(x,n)
a matrix or multidimensional array.
an integer by which the dimension of the given array is to be shifted.
dimension shifted array
Amount of shift introduced.
It shifts the dimension of a multi-dimensional array by a given amount and direction specified in the second argument. If the second argument is positive, it shifts the dimension to the left and if negative it shifts the dimension to the right.
r=rand(3,4,3); y=shiftdim(r,2); | ![]() | ![]() |