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!