Description

Assigns a value to each element in a matrix. All elements can be assigned the same value. Or, values can be set equal to the corresponding values in a second matrix.

Syntax

Mat matrix = expression

- OR -

Mat matrix = Mat matrix2

Parameters

The Mat statement has the following parameters.

ParameterDescription
MatrixSpecifies the name of the matrix whose elements are being assigned. The matrix must have been previously named and dimensioned in a Dimension statement.
ExpressionEquates to a value; assigned to each of the elements in the matrix. Any legal expression may be used. In the following example, all the elements of array X are assigned the current value of A*B+C: Mat X = A * B + C
matrix2The values of the elements of matrix2 are assigned to the elements of matrix. Both matrices must have been named and dimensioned, and they must contain exactly the same number of elements. The dimensions may differ, but the total number of elements must be the same. For example, X(20), Y(4,5), and Z(2,10) are dimensioned differently, but have the same number of elements. The elements are assigned in corresponding order: the value of the ith element of matrix2 is assigned to the ith element of matrix. The elements of matrix2 remain unchanged.

See also

CallDeclareDimensionFunctionSubroutine

Remarks

The Mat keyword is required to pass an array to a subroutine or a function. The Mat statement is part of the argument list, and is separated from any other arguments by a comma. Both the calling program and the subroutine or function must use the Mat statement as part of the argument list. The matrix must be dimensioned before it is passed.

Example

/* The element values in MATRIX2 will be assigned to MATRIX1 such that MATRIX1(0) would have 0, MATRIX1(1,1) would have 1, MATRIX1(1,2) would be 2, and so forth. 
Then all elements of MATRIX2 are set to null. */
Dim MATRIX1(3,4), MATRIX2(12)
For CTR = 1 to 12
       MATRIX2 (CTR) = CTR
Next CTR
Mat MATRIX1 = Mat MATRIX2
Mat MATRIX2 = ""
/* The matrix CUST.REC and the variables YR and MO are passed as arguments. */
Call CREDIT(Mat CUST.REC, YR, MO)
  • No labels