Set Matrix Elements (G Dataflow)

Sets one or more elements in matrix at the indexes you specify in index (row) and index (col).

Programming Patterns

If you wire scalar values i and j to index (row) and index (col), respectively, these inputs correspond to a single matrix element at location (i, j).

matrix

2D array of any numeric type.

index (row)

Integer, floating-point numeric, 1D array of integers, or 1D array of a floating-point numeric.

Default: 0

index (col)

Integer, floating-point numeric, 1D array of integers, or 1D array of a floating-point numeric.

Default: 0

new element/submatrix

Scalar or 2D array that replaces one or more elements in matrix.

output matrix

matrix with the new elements. If matrix is an empty matrix, output matrix resizes to receive the new elements.

Output Behavior with 1D Arrays

If you wire a 1D array of numeric data to index (row) or index (col), this node sets one matrix element for each location specified. To determine these locations this node pairs each row index in index (row) with each column index in index (col). For example, if you pass the array of integers {1, 2, 4} to index (row) and the integer {5} to index (col), this node modifies matrix elements at indexes (1, 5), (2, 5), and (4, 5).

Empty or Unwired Input Values

If you leave inputs empty or unwired, this node behaves as described in the following table.

Input Result
You wire an empty 1D array to index (row) or index (col). output matrix returns matrix.
You do not wire index (row) or index (col). This node assigns the new element to the input matrix starting at index (0, 0).
You do not wire an input to new element/submatrix. This node sets the element at location (index (row), index (col)) in matrix to 0.

Indexing Outside Input Values

If you wire certain values to index (row) or index (col) that are outside the existing elements of matrix, output matrix resizes as described in the following table.

Input Result
You wire a value to index (row) or index (col) that is greater than or equal to the row or column dimension of matrix. output matrix resizes to receive elements at the corresponding location. If you increase the row or column dimensions of matrix, this node returns an invalid operation value at each exterior location.
The location you specify in index (row) and index (col) is outside matrix and all the inputs are non-negative. output matrix resizes to accept the new element or matrix.

Indexing Identical Values

If you wire identical values to index (row) or index (col) and you wire a matrix to new element/submatrix, the order in which this node sets the new matrix elements determines output matrix.

Wiring the New Element/Submatrix Input

When you wire inputs to new element/submatrix, this node behaves as described in the following table.

Input Result
You wire a matrix to new element/submatrix that has a dimension larger than matrix. output matrix resizes to receive the new matrix elements. If you increase the row or column dimensions of matrix, this node returns 0 at each exterior location.
You wire a matrix to new element/submatrix that is larger than the largest submatrix at the starting location. output matrix resizes to receive the new matrix elements. If you increase the row or column dimensions of matrix, this node returns 0 at each exterior location.
You wire a matrix to new element/submatrix in which the row or column dimensions exceed the respective number of row indexes in index (row) or column indexes in index (col). This node ignores the additional row and column elements.
You wire a matrix to new element/submatrix in which the number of row indexes is less than the row dimension of output matrix and you wire a 1D array to index (row). This node inserts an invalid operation value at each exterior location.
You wire a matrix to new element/submatrix in which the number of column indexes is less than the column dimension of output matrix and you wire a 1D array to index (col). This node inserts an invalid operation value at each exterior location.
You wire an input to new element/submatrix with a different numeric type than matrix. This node converts matrix to a new numeric type if this node cannot set new elements without losing precision. If this node can set new elements without losing precision, the numeric type of new element/submatrix converts to the numeric type of matrix.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application