hist3 not returning expected output
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!