histcount2 を使うと良いかと思います。以下の N でテーブル(行列) を得られます。
https://jp.mathworks.com/help/matlab/ref/histcounts2.html
x = randn(100,1);
y = randn(100,1);
[N,Xedges,Yedges] = histcounts2(x,y)
histogram2(x,y,Xedges,Yedges)
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!