title: Is there a way to group matrix elements in matlab?
body: <p>I am working on a problem which requires me to group array elements and average each group. For example consider the 4 x 4 matrix M,</p>
  <pre><code>M = [ 1 0 0 1;
        1 0 1 1;
        1 1 0 1;
        0 0 0 1;]
  </code></pre>
  <p>I want to group this into a 2 x 2 matrix, taking an average of the elements so we would get</p>
  <pre><code>M1 = [0.5 0.75;
        0.5 0.5;]
  </code></pre>
  <p>does anyone know a way to do this?</p>
  <p>Many thanks</p>