<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Le 08/11/2017 à 15:07, Richard llom a
      écrit :<br>
    </div>
    <blockquote cite="mid:1510150051523-0.post@n3.nabble.com"
      type="cite">
      <pre wrap="">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.</pre>
    </blockquote>
    <br>
    If you need to shift i = 1:n indices by <i>any</i> p -- not
    necessarily n/2 --, you may do<br>
    <tt><br>
      si = modulo(i+p-1, n)+1    // with n = length(i);</tt><tt><br>
    </tt><br>
    Example:<br>
    i = 1:10, p = 2;<br>
    si = modulo(i+p-1, length(i))+1<br>
    <tt>--> i = 1:10, p = 2;</tt><tt><br>
    </tt><tt> i  = </tt><tt><br>
    </tt><tt>   1.   2.   3.   4.   5.   6.   7.   8.   9.   10.</tt><tt><br>
    </tt><tt><br>
    </tt><tt>--> si = modulo(i+p-1, length(i))+1</tt><tt><br>
    </tt><tt> si  = </tt><tt><br>
    </tt><tt>   3.   4.   5.   6.   7.   8.   9.   10.   1.   2.</tt><tt><br>
    </tt><br>
    Samuel<br>
    <br>
  </body>
</html>