"histcounts makes a rounding decison when a value is exactly on a a bin edge."
No, you misunderstand how histcounts works. As I said it doesn't do any rounding.
As documented, The value X is in the bin if except for the last bin where the the right edge is part of the bin. So, yes if you have an edge at 2.5, the value 2.5 will be part of the 2.5+ bin, no rounding involved. Now, I thought there was a way to reverse this so that's it's the right edge that is included in bin k instead of the left edge but I was surprised to find that this option is only available for discretize which is very similar in some way.
So, if you want 2.5 to be included in the [2, 2.5] bin, you have two options:
1. Change your bin definition so that the right edge is not 2.5 but the next number up, which is 2.5 + eps(2.5):
edges = [0, 0.5, 1, 1.5, 2, 2.5, 3]
edges(2:end-1) = edges(2:end-1) + eps(edges(2:end-1));
2. Do an indirect trip through discretize:
edges = [0, 0.5, 1, 1.5, 2, 2.5, 3];
bin = discretize(yourvector, edges, 'IncludedEdge', 'right');
newedges = 1:numel(edges)
result = histcounts(yourvector, newedges, ..your_histcounts_options);