if

March 6th, 2008 Posted in Controls

statement condition.
The general form of the if statement is

if expression

expression
statements
ELSE
statements

The statements are executed if the real part of the expression
has all non-zero elements. The ELSE and ELSEIF parts are optional.
Zero or more ELSEIF parts can be used as well as nested IF’s.
The expression is usually of the form expr rop expr where
rop is ==, <, >, <=, >=, or ~=.

Example
if I == J
A(I,J) = 2;
elseif (I-J) == 1
A(I,J) = -1;
else
A(I,J) = 0;
end

See also relop, else, elseif, end, , while, .

Leave a Reply

You must be logged in to post a comment.