elseif

Other statement in an if-else expression if no previous 'if' condition are met.

Syntax

if (condition)
  statement
elseif (ElseCondition) 
  statement
else
  statement
end
b

Inputs

condition
Anything that can be logically tested.
Type: double | char | logical | struct | cell | integer
Dimension: scalar | vector | matrix
ElseCondition
Anything that can be logically tested.
Type: double | char | logical | struct | cell | integer
Dimension: scalar | vector | matrix

Outputs

statement
Any statement that can be executed.
Type: double | char | logical | struct | cell | integer
Dimension: scalar | vector | matrix | statement | function

Example

Simple if-else example:

a=2;
if (a==0)
  b=0;
elseif a==2
  b=1;
end
b

b = 1