%% Return Bin Numbers for Histogram
% Defined ages as a vector of ages. Sort ages into bins with varying ranges between 0 and 75.

ages = [3,12,24,15,5,74,23,54,31,23,64,75];
binranges = [0,10,25,50,75];

[bincounts,ind] = histc(ages,binranges)

% bincounts contains the number of values in each bin. ind indicates the bin numbers.
% Copyright 2015 The MathWorks, Inc.