What is the logic behind contradicting bins in the function histc?
Show older comments
I am trying to understand a certain behavior of MATLAB's function histc. The bin ranges should be monotonically non-decreasing, however, when repeating edges are present, MATLAB does not throw an error. Instead the following happens:
binranges = [-Inf 3 4 4 5 Inf];
a = [4 3];
histc(a,binranges)
ans = [0 1 0 1 0 0]
According to my understanding, MATLAB creates the following six bins:
-Inf <= x1 < 3
3 <= x2 < 4
4 <= x3 < 4 ??
4 <= x4 < 5
5 <= x5 < Inf
Inf = x6
In the bin 4 <= x3 < 4, MATLAB counts 0, which somehow makes sense since a number cannot be equal to and strictly less than a specific value at the same time. Is there a rationale behind this contradicting bin or why does it exists?
Accepted Answer
More Answers (0)
Categories
Find more on Introduction to Installation and Licensing 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!