how to cyclically shift an array?

3 Ansichten (letzte 30 Tage)
bsd
bsd am 11 Dez. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Dez. 2011

Weitere Antworten (1)

Mohsen  Davarynejad
Mohsen Davarynejad am 11 Dez. 2011
x = [1 : 1 : 10]
for i = 1 : 5
x = [x(2:end) x(1)]
end
  1 Kommentar
Jan
Jan am 11 Dez. 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]".

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by