# circshift

Circular shift.

## Syntax

y = circshift(x,n)

y = circshift(x,n,dim)

## Inputs

x
The matrix or string whose elements are to be shifted.
Type: double | complex | char
Dimension: vec | mat | string
n
If n is a vector, it specifies integer values by which to shift each dimension of x, and the third input dim does not apply.
If n is an integer, the shift applies only along the dimension dim.
Type: integer
Dimension: integer | vec
dim
The dimension on which to operate.
Default: the first non-singleton dimension.
Type: integer
Dimension: scalar

## Outputs

y
The shifted result.

## Examples

Shifting a row vector:

``````x = [1:8]
y = circshift (x, 3)``````
``````x = [Matrix] 1 x 8
1  2  3  4  5  6  7  8
y = [Matrix] 1 x 8
6  7  8  1  2  3  4  5``````

Shifting one matrix dimension:

``````x = [1, 4, 7, 10; 2, 5, 8, 11; 3, 6, 9, 12]
y = circshift (x, 3, 2)``````
``````x = [Matrix] 3 x 4
1  4  7  10
2  5  8  11
3  6  9  12
y = [Matrix] 3 x 4
4  7  10  1
5  8  11  2
6  9  12  3``````

Shifting two matrix dimensions:

``````x = [1, 4, 7, 10; 2, 5, 8, 11; 3, 6, 9, 12]
y = circshift (x, [2,3])``````
``````x = [Matrix] 3 x 4
1  4  7  10
2  5  8  11
3  6  9  12
y = [Matrix] 3 x 4
5  8  11  2
6  9  12  3
4  7  10  1``````