|MATLAB Function Reference|
Conditionally execute statements
else is used to delineate an alternate block of statements. If
expression evaluates as
false, MATLAB executes the one or more commands denoted here as
true expression has either a logical 1 (
true) or nonzero value. For nonscalar expressions, (for example, "if (matrix A is less than matrix B)"),
true means that every element of the resulting matrix has a
true or nonzero value.
Expressions usually involve relational operations such as
(count < limit) or
isreal(A). Simple expressions can be combined by logical operators (
~) into compound expressions such as
(count < limit) & ((height - offset) >= 0).
if for more information.
In this example, if both of the conditions are not satisfied, then the student fails the course.
return, relational operators, logical operators (elementwise and short-circuit)
© 1994-2005 The MathWorks, Inc.