if

conditional statement.

Syntax

  • if conditional_expression_1, statements_1, elseif conditional_expression_2, statements_2, else statements_N end

Description

if and else statements form a control structure for conditional execution.

Example

i = 0;
if i == 0
  disp('ok')
elseif i == 1
  disp('not ok 1')
else
  disp('not ok 2')
end

See also

for.

History

VersionDescription

1.0.0

initial version

Author

Allan CORNET

Last updated