%% Determine Bin Placement
% Distribute 1,000 random integer pairs between -10 and 10 into bins, and specify BinMethod as 'integers' to use unit-width bins centered on integers. Specify five outputs for histcounts2 to return vectors representing the bin placement of the data.

x = randi([-10,10],1000,1);
y = randi([-10,10],1000,1);
[N,Xedges,Yedges,binX,binY] = histcounts2(x,y,'BinMethod','integers');

%
% Determine which bin the value (x(3),y(3)) falls into.

[x(3),y(3)]

%

bin = [binX(3) binY(3)]

% Copyright 2015 The MathWorks, Inc.