title: Sorting items into bins in MATLAB
body: <p>If I have a set of data Y and a set of bins centered at X, I can use the HIST command to find how many of each Y are in each bin.  </p>
  
  <pre><code>N = hist(Y,X)
  </code></pre>
  
  <p>What I would like to know is if there is a built in function that can tell me which bin each Y goes into, so</p>
  
  <pre><code>[N,I] = histMod(Y,X)
  </code></pre>
  
  <p>would mean that Y(I == 1) would return all the Y in bin 1, etc.</p>
  
  <p>I know how to write this function, so I am only wondering if there is already a built-in in MATLAB that does this.</p>