Statements

A statement is a complete instruction to the OpenMatrix language. Statements typically combine keywords and expressions.

Consider:
A=sin(1+1)
sin(1+1) is an expression. 1+1 is also an expression.A=sin(1+1) is a statement.
A statement may consist of multiple lines of script, including other statements. For example:
if (a==0)
  b=0
else
  b=1
end
is considered to be a single statement, even though b=0 and b=1 are also statements.

Statement Output

Each statement produces at least one output. If the statement is an assignment to a variable (or an element of a variable), then the output will be of the form:

variable = value

If the statement is NOT an assignment to a variable, then the output of the statement is automatically assigned to a special variable called 'ans.' The variable 'ans' can thereafter be used just like any other variable. The output will be of the form:

ans = value.

In order to suppress the output from a statement, a ; can be appended to the end of the statement. No output is displayed, but the 'ans' variable is assigned as it normally would.

Examples:
a=4          a=4
1+1          ans=2
a=[4,0;0,2] 
a(2,2)       ans=2
1+1;         <empty>