mat Statement

The mat statement assigns data to each element of a dimensioned array variable to a specific value in one operation.

Syntax

mat array.var = exp 

mat array.var1 = mat array.var2 

Description

Array variables must be defined in a dim, common, or file statement.

Example(s)

Copies one array into another. The number of elements in array.var1 must be greater than or equal to the number of elements in array.var2. It is possible to assign a two-dimensional array to a single-dimensional array and conversely.

Dim array(5)

qty = 10

mat array = qty

 

dim one(4,1)

mat one = 1

dim two(2,2)

mat two = mat one

 

NOTE

When assigning one matrix to another, the array to the right of the equal sign must have the same total number of elements as the matrix to the left of the equal sign.

This sets every array element of customer.item to null.

mat customer.item = ""

This sets every array entry of customer.item.history to its corresponding entry in customer.item.

mat customer.item.history = mat customer.item

This example assigns all of the elements in the two dimensional array, a into the one dimensional array, b. The rows are filled before the columns, therefore a(2,1) = 2.

dim a(10,2)

dim b(20)

mat b = 1

b(3) = 2

mat a = mat b

See Also

Assignment

matread Statement

matwrite Statement

Statements and Functions