Your error is on this line (the error message probably even says as much):
nelements = hist(thresh_strain(:),myUniqueValues);
The problem is that myUniqueValues
is not "monotonically non-decreasing." This example produces the same error:
n = hist(randi(3,[1 10]),[3 2 1]);
which results in
Error using histc
Edge vector must be monotonically non-decreasing.
Error in hist (line 92)
nn = histc(y,edges,1);
I'm not sure what this is happening as unique
is supposed to sort it's output. So I can't replicate your error exactly in R2013b. Perhaps you're running an older version of Matlab. I'd look at what the value of myUniqueValues
is.