Look at histcounts2():
x = randn(npoints,1)*500;
y = randn(npoints,1)*300;
counts = histcounts2(x,y,edx,edy).';
Play around with it with some asymmetric data so you understand the orientation of the output. You may find it more intuitive to transpose the counts array like I did here.
If you want to visualize the results:
(scaled up, obviously)