MAT Statement

The MAT statement may be used either to assign a single value to all elements of an array, or to copy all elements of one array into another.

Format

MAT array = expr

MAT array1 = MAT array2

Parameter(s)

MAT array = expr

Assigns the evaluated value of expr to all elements of the array.

MAT array1 = MAT array2

Assigns each element of array1 to the corresponding element in array2. The arrays thus become equivalent. Note that each array must have been dimensioned via the DIMENSION statement to have the same number of elements, although the actual dimensions do not need to be identical. The elements are assigned in consecutive order, regardless of whether the dimensions are the same.

Description

The MAT statement may be used only for assigning a value to all elements of an array or to make two arrays equivalent in data. It cannot be used to perform matrix arithmetic.

In passing a dimensioned array to an external subroutine, the MAT keyword must precede the array name. See CALL Statement for more information.

Example

If the array ARR1 has been dimensioned to be a 12 element vector and the array ARR2 has been dimensioned to a 3 X 4 matrix, ARR1 may be assigned the elements of ARR2 with:

MAT ARR1 = MAT ARR2

If ARR2 contained:

 

1

2

3

4

1

FIRST

SECOND

THIRD

FOURTH

2

FIFTH

SIXTH

SEVENTH

EIGHTH

3

NINTH

TENTH

ELEVENTH

TWELFTH

then ARR1 will contain:

1

FIRST

2

SECOND

3

THIRD

4

FOURTH

5

FIFTH

6

SIXTH

7

SEVENTH

8

EIGHTH

9

NINTH

10

TENTH

11

ELEVENTH

12

TWELFTH

See Also

Statement and Function Reference