next up previous
Next: MATC general flow control Up: MATC Matrix Language Previous: MATC Matrix Language

MATC Variables

There are two types of variables in MATC: matrices and strings. Both are actually stored the same way in a double precision array, so that storing large arrays of strings is wasteful sizewise.

A variable is created by assigning value to it:

equation5

The above statement creates a tex2html_wrap_inline163 matrix whose name is x.

The statement

equation7

creates a tex2html_wrap_inline167 string variable k. That is, string variables are created with enclosed in ''''-marks.

Variables can be indexed by two row vectors. The statement

equation9

reverses the order of the first six elements of the first row of a variable called x. Indexing thus begins from zero.

Yet one example of creating a variable (or affecting its values) is

equation11

Variable x will be a tex2html_wrap_inline175 matrix, if not previously created and bigger. It's elements are

1 2 3 4 1 2 3 4 1 2.
The example shows that you don't have to give the row index if it's zero, and that when scanning for values for elements, the values end, they are repeated from the beginning.

Size of the variables are dynamic. If variable x is non-existent the statement

equation13

creates a new matrix whose size is tex2html_wrap_inline179 and is zero except for the last element whose value is 1.

Another way of indexing a matrix is logical expression whose size is the same as the matrix which is being indexed. The statement

equation15

sets the values of matrix x which are less than 0.05 to the value 0.05.



Juha Ruokolainen
Fri Feb 14 15:59:30 EET 1997