Le 08/11/2017 à 15:07, Richard llom a écrit :
Hello,
is there a function available to shift indices?
E.g. I have
aa = [1:10]
and want
bb =  6.   7.   8.   9.   10.   1.   2.   3.   4.   5.

If you need to shift i = 1:n indices by /any/ p -- not necessarily n/2 --, you may do

si = modulo(i+p-1, n)+1    // with n = length(i);

Example:
i = 1:10, p = 2;
si = modulo(i+p-1, length(i))+1
--> i = 1:10, p = 2;
 i  =
   1.   2.   3.   4.   5.   6.   7.   8.   9.   10.

--> si = modulo(i+p-1, length(i))+1
 si  =
   3.   4.   5.   6.   7.   8.   9.   10.   1.   2.

Samuel

_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to