hist3 not returning expected output
1 次查看(过去 30 天)
显示 更早的评论
I was trying to use hist3 to visually display a two-dimensional distribution, however the function behaves unexpectedly. I thought that it returns a 2D histogram (a count) of how many times each pair of numbers in the input matrix occurs, and displays that count at a position in the output matrix whose indices correspond to that number pair, scaled to a factor of 10 (by default) or some other square-matrix size. But this is not what my test examples showed.
If I define the following input matrix
1 1
2 2
3 3
4 4
5 5
then the command
v=hist3(m, [5 5])
has the following output (as expected):
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
However for this input matrix:
4 1
4 2
4 3
4 4
4 5
the output is:
0 0 0 0 0
0 0 0 0 0
1 1 1 1 1
0 0 0 0 0
0 0 0 0 0
..rather than (as I would have expected):
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 1 1 1 1
0 0 0 0 0
Can anyone help clear the confusion? THanks!
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!