www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/ReturnBinNumbersForHistogramExample.m
%% Return Bin Numbers for Histogram % Defined |ages| as a vector of ages. Sort |ages| into bins with % varying ranges between 0 and 75. % Copyright 2015 The MathWorks, Inc. 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.