title: Averaging every n elements of a vector in matlab
body: <p>I would like to average every 3 values of an vector in Matlab, and then assign the average to the elements that produced it.</p>
  
  <p>Examples:</p>
  
  <pre><code>x=[1:12];
  y=%The averaging operation;
  </code></pre>
  
  <p>After the operation, </p>
  
  <pre><code>y=
  [2 2 2 5 5 5 8 8 8 11 11 11]
  </code></pre>
  
  <p>Therefore the produced vector is the same size, and the jumping average every 3 values replaces the values that were used to produce the average (i.e. <code>1 2 3</code> are replaced by the average of the three values, <code>2 2 2</code>). Is there a way of doing this without a loop?</p>
  
  <p>I hope that makes sense.</p>
  
  <p>Thanks.</p>