I am working on a project which requires making discrete values out of numeric quantities all over the place. At present I’m using cascaded if / elseif / else constructs, for example:
if M > 6
evidence{2} = 3;
elseif M > 2
evidence{2} = 2;
else
evidence{2} = 1;
end
I want to replace this with a more maintainable (and concise) syntax, but before I come up with my own idiom I would like to know if there is already a convenient function or syntax available in MATLAB. Any suggestions?
How about:
Basically, you are searching for the interval in which M lies: (-inf,2], (2,6], (6,+inf)
So even if your values were not 1/2/3, you could then map the range index found to some other values…