MATLAB: Threshold calculation without “if else”

ifImage Processing Toolboxthreshold

Given following logic
T=1, if x < m1
T=2, if x >= m1 && x < m2
T=3, if x >= m2 && x < m3
T=4, if x >= m3
x is a parameter; m1, m2, m3 are thresholds to determine the conversion from x to T. Is there a way to calculate T without using "if"? Say, "rem" or "mod" or something without logic operation?

Best Answer

T = 1 + (x >= m1) + (x >= m2) + (x >= m3)
would work. May not be more efficient that if though.