【发布时间】:2016-06-01 17:58:06
【问题描述】:
我正在寻找一种使用索引值进行循环移位的方法。
我知道我可以使用下面的 circshift 命令移动所有值
a=[1:9]
b=circshift(a,[0,1])
但是如何将每 3 个值移到 1 以上?
例子:
注意:变量a可以是任意长度
a=[1,2,30,4,5,60,7,8,90] %note variable `a` could be any length
我正在努力让b 成为
b=[1,30,2,4,60,5,7,90,8] % so the values in the index 3,6 and 9 are shifted over 1.
【问题讨论】: