tcounts = histc(-Y, fliplr(-[a, b, c, d]) );
counts = fliplr(tcounts(1:end-1));
The reason for taking negatives and using fliplr is that histc uses [x1,x2), [x2,x3), [x3,x4), [x4,x4] as the boundaries, whereas you want (x1, x2], (x2, x3], (x3, x4]. Going for the negative flips the ends around allowing us to construct the boundaries [-x4, -x3), [-x3, -x2), [-x2, -x1), [-x1, -x1] which has the right open/close semantics for your purposes. We then flip the counts end for end to get them in the right order, discarding the [a a] bin as we do so because you are not interested in the counts for values exactly equal to a.
If you were willing to accept semi-open instead of semi-closed then you could just use
counts = histc(y, [a, b, c, d]);
and then discard the last bin which would be the counts for values exactly equal to d.
Best Answer