%% Group Data into Bins
% Use discretize to group numeric values into discrete bins. edges defines five bin edges, so there are four bins.

data = [1 1 2 3 6 5 8 10 4 4]

%

edges = 2:2:10

%

Y = discretize(data,edges)

% Y indicates which bin each element of data belongs to. Since the value 1 falls outside the range of the bins, Y contains NaN values for those elements.
% Copyright 2012 The MathWorks, Inc.