title: Binning in matlab
body: <p>I have been unable to find a function in matlab or octave to do what I want.
  I have a matrix m of two columns (x and y values).  I know that I can extract the column by doing m(:,1) or m(:,2).  I want to split it into smaller matricies of [potentially] equal size and and plot the mean of these matricies.  In other words, I want to put the values into bins based on the x values, then find means of the bins.  I feel like the hist function should help me, but it doesn't seem to.</p>
  
  <p>Does anyone know of a built-in function to do something like this?</p>
  
  <p><em>edit</em></p>
  
  <p>I had intended to mention that I looked at hist and couldn't get it to do what I wanted, but it must have slipped my mind.</p>
  
  <p>Example:  Let's say I have the following (I'm trying this in octave, but afaik it works in matlab):</p>
  
  <pre><code>x=1:20;
  y=[1:10,10:1];
  m=[x, y];
  </code></pre>
  
  <p>If I want 10 bins, I would like m to be split into:</p>
  
  <pre><code>m1=[1:2, 1:2]
  ...
  m5=[9:10, 9:10]
  m6=[10:11, 10:-1:9]
  ...
  m10=[19:20, 2:-1:1]
  </code></pre>
  
  <p>and then get the mean of each bin.</p>
  
  <p>Update: I have posted a follow-up question <a href="https://stackoverflow.com/questions/427221/better-non-linear-binning">here</a>.  I would greatly appreciate responses.</p>