mercredi 14 septembre 2016

Conditional "Or" Statements in MATLAB

I am under the impression that || is the "or" statement in MATLAB. Perhaps someone can explain the confusing behaviour I am seeing:

a = 2;

a == 2        %returns ans = 1 (true)

a == 2 || 3   %returns ans = 1 (true)

a == 3 || 4   %returns ans = 1 (true)??!!

What am I missing here? 'a' is neither 3 or 4, so shouldn't

a == 3 || 4

return ans = 0 (false)?

Aucun commentaire:

Enregistrer un commentaire