if expression, statements,
end evaluates an expression,
and executes a group of statements when the expression is true. An
expression is true when its result is nonempty and contains only nonzero
elements (logical or real numeric). Otherwise, the expression is false.

The elseif and else blocks
are optional. The statements execute only if previous expressions
in the if...end block are false. An if block
can include multiple elseif blocks.

An expression can include relational operators
(such as < or ==) and logical
operators (such as &&, ||,
or ~). Use the logical operators and and or to
create compound expressions. MATLAB^{®} evaluates compound expressions
from left to right, adhering to operator precedence rules.

Within the conditional expression of an if...end block,
logical operators & and | behave
as short-circuit operators. This behavior is the same as && and ||,
respectively. Since && and || consistently
short-circuit in conditional expressions and statements, it is good
practice to use && and || instead
of & and | within the expression.
For example,

x = 42;
if exist('myfunction.m','file') && (myfunction(x) >= pi)
disp('Expressions are true')
end

The first part of the expression evaluates to false. Therefore, MATLAB does
not need to evaluate the second part of the expression, which would
result in an undefined function error.