Contents Previous Next Subchapters

If Statement (Mlmode)
Syntax if expression 
     
list of statements 
elseif 
expression
     
list of statements 
else 
expression
     
list of statements 
end
O-Matrix Mode if

Description
Each if token begins a block without needing the begin keyword. If any element of the expression following the if is zero, the expression is considered false. In addition, the keyword elseif can be used to terminate one block and begin another.

Note that when an if is input at the command line, execution will not occur until the corresponding end is entered.

Example
If in Mlmode you enter
     x = 1;
     if x <= 0 
          0
     elseif x <= 1
          1
     else
          2
     end
O-Matrix will reply
     1


If you enter
     x = [ 1 0 ];
     if x
          1
     else
          2
     end
O-Matrix will respond
     2