Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wondering how to compare 3 variables in MATLAB, because MATLAB is comparing first 2 and then result against 3rd. To illustrate with example:

(-1 == -1 == -1)

ans =


(-1 == -1 == 1)

ans =


My dataset that I am comparing has only -1 and +1 values. Is the only solution is to convert everything to 1's and 0's?

share|cite|improve this question
up vote 0 down vote accepted

How about:

(a == b) && (b == c)
share|cite|improve this answer
Came here to reply to my own question and found out that it is answered! Thanks! – jpou Nov 4 '12 at 12:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.