MATLAB: Discretize function matlab/number falling to more than one histogram bins

discretizehistogram

p=[0 100 0 0 0]; % vector of probability mass
cump=cumsum(p); %cumulative probability mass
X=100; %value for which I extract the bin index
Y=discretize(X,cump);
cump = 1×5
0 100 100 100 100
Y = 4
Hi , in this piece of code , I insert a probability value between 0-100 (0-1 probability) , and by using the discretize function I am checking the index of the bin that this value belongs. The thing is that when this value X is 100 , and the cumulative probability is : [0 100 100 100 100] , I would like the index result to be the 1st bin(or at least the 2nd bin, not the last one.).This cannot happen since each bin includes the left edge, but does not include the right edge, except for the last bin which includes both edges. Is there anyway to fix this problem?
Thanks

Best Answer

[___] = discretize(___,'IncludedEdge',side)
I used this command ,to include the right edge of the bind, and now the problem is solved