MATLAB: 10>6>4

.gt10 6 4binary operatorgelelogical operatorsltMATLABternary operatortwo greater than s...two greater than signs

I am reviewing for a test and one of the questions is "what would be the outcome of 10>6>4?" I thought it would be logical: 1 because all the statements are true, but when I put it into MATLAB it returned logical: 0 for any number I used. Can anyone explain this?

Best Answer

"Can anyone explain this?"
MATLAB has a binary operator gt, e.g. A>B, but it does not have a ternary operator A>B>C. So your example
10>6>4
is exactly equivalent to this:
(10>6)>4
The part in the parentheses will only ever return the values 0 (false) or 1 (true), so the second comparison will always return false (unless you reduce the value 4 to 0 or less).