how to cyclically shift an array?

2 views (last 30 days)
bsd
bsd on 11 Dec 2011
Hai,
I have an array of elements, I need to shift them cyclically to the left. How could I do it in matlab? Looking forward for your reply.
BSD

Accepted Answer

Walter Roberson
Walter Roberson on 11 Dec 2011

More Answers (1)

Mohsen  Davarynejad
Mohsen Davarynejad on 11 Dec 2011
x = [1 : 1 : 10]
for i = 1 : 5
x = [x(2:end) x(1)]
end
  1 Comment
Jan
Jan on 11 Dec 2011
The FOR loop might be confusing here. It is useful to demonstate the repeated operation only.
"1:10" is nicer and faster than "[1:1:10]".

Sign in to comment.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!