MATLAB Function Reference |

Conditionally execute statements

**Syntax**

**Description**

`else`

is used to delineate an alternate block of statements. If

evaluates as *expression*`false`

, MATLAB executes the one or more commands denoted here as

.*statements2*

A `true`

expression has either a logical 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 logical 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)`

.

See `if`

for more information.

**Examples**

In this example, if both of the conditions are not satisfied, then the student fails the course.

**See Also**

`if`

, `elseif`

, `end`

, `for`

, `while`

, `switch`

, `break`

, `return`

, `relational_operators`

, `logical_operators`

ellipsoid | elseif |