title: matlab: dividing vector into overlapping chunks of fixed size
body: <p>I've a vector that I would like to split into overlapping subvectors of size <code>cs</code> in shifts of <code>sh</code>. Imagine the input vector is:</p>
  
  <pre><code>v=[1 2 3 4 5 6 7 8 9 10 11 12 13]; % A=[1:13]
  </code></pre>
  
  <p>given a <code>chunksize</code> of 4 (<code>cs=4</code>) and shift of 2 (<code>sh=2</code>), the result should look like:</p>
  
  <pre><code>[1 2 3 4]
  [3 4 5 6]
  [5 6 7 8]
  [7 8 9 10]
  [9 10 11 12]
  </code></pre>
  
  <p>note that the input vector is not necessarily divisible by the <code>chunksize</code> and therefore some subvectors are discarded. Is there any fast way to compute that, without the need of using e.g. a <code>for</code> loop?
  In a related <a href="https://stackoverflow.com/questions/5525186/matlab-dividing-chunks-of-data-randomly-into-equal-sized-sets">post</a> I found how to do that but when considering non-overlapping subvectors.</p>