Navigation

Operators and Keywords

Function List:

C++ API

Function File: y = circshift (x, n)

Circularly shift the values of the array x.

n must be a vector of integers no longer than the number of dimensions in x. The values of n can be either positive or negative, which determines the direction in which the values or x are shifted. If an element of n is zero, then the corresponding dimension of x will not be shifted. For example:

x = [1, 2, 3; 4, 5, 6; 7, 8, 9];
circshift (x, 1)
⇒  7, 8, 9
    1, 2, 3
    4, 5, 6
circshift (x, -2)
⇒  7, 8, 9
    1, 2, 3
    4, 5, 6
circshift (x, [0,1])
⇒  3, 1, 2
    6, 4, 5
    9, 7, 8

See also: permute, ipermute, shiftdim.

Package: octave