if, else, elseif
if logical_expression_1
block1
elseif logical_expression_2
block2
else
block3
end
- The
elseif and else clauses are optional
- With
else present, the conditional is exhaustive
elseif may appear any number of times, peer to if and else and mutually exclusive with them
- logical_expression_i is a conditional expression—one that returns a logical value—typically built with Matlab Relational Operations and Matlab Logical Operations
- logical_expression_i may also be any array A, in which case it is equivalent to the conditional expression
all(A(:))
- However, when A is an empty array, A in this position is equivalent to logical false
0, while all(A(:)) returns logical true 1