You have encountered ‘floating-point approximation error’. Most numbers are not exactly represented in floating-point precision (especially if they are the result of computations), so testing for them exactly is not usually productive. See the documentation on Floating-Point Numbers for an extended discussion. Taking that into account, finding the indices of the ‘-10’ elements is relatively straightforward.
For example:
Returns = (0.5-rand(1, 1E+4))*30;
Lv = ismembertol(Returns, -10, 0.01);
Indices = find(Lv);
Use your vector instead of my test vector. Experiment with the tolerance value (here 0.01) to get the result you want.
See if plotting with a marker (instead of a line) will make your data more visible. I cannot offer you any advice with respect to the histogram. We do not have your data or know what result you want, so you will need to experiment.
Best Answer