I just posted a blog on logical operator behavior in MATLAB and I want to be clear about the bottom line.
Use the newer MATLAB operators || and &&, in the context of expressions for if and while. The newer operators always short-circuit, not just in if and while expressions. The newer operators force you to be clear about your intention with respect to matrix expressions (including empty ones) and you choose how to reduce the array expressions to scalar ones that are unambiguous.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.