circshift
Circularly shift elements of an array.
Syntax
Section titled “Syntax”B = circshift(A, shiftsize)Description
Section titled “Description”Cycles the elements of A by shiftsize positions. shiftsize is either a scalar (shift along the first non-singleton dimension) or a vector (one shift per dimension). Positive values shift forward (toward higher indices); negative values shift backward. Elements wrapped past the boundary reappear at the opposite end.
Examples
Section titled “Examples”circshift([1 2 3 4 5], 2) % [4 5 1 2 3]circshift([1 2 3 4 5], -1) % [2 3 4 5 1]circshift(magic(4), [1 2]) % shift down 1, right 2