Sidechair

matrix.get()

Browse the reference

Returns the item in a given row and column of a matrix.

Try it in the editor

Both indexes count from 0. matrix.get(m, 0, 2) is the first row's third item. A row or column outside the matrix stops the script with an error.

Reading does not change the matrix; use matrix.row() or matrix.col() to take a whole line at once.

Syntax

Pine Script
matrix.get(id: any matrix type, row: series int, column: series int) -> <matrix_type>
matrix.get(row: series int, column: series int) -> <matrix_type>

Arguments

NameTypeDefaultDescription
idany matrix typerequiredThe matrix to read an item from. The matrix itself is not changed.
rowseries intrequiredIndex of the row. Counts from 0.
columnseries intrequiredIndex of the column. Counts from 0.

Returns

<matrix_type>: The item at that row and column.

Example

Pine ScriptRead the cornerOpen in editor
//@version=6
indicator("matrix.get: corner", overlay = false)
matrix<float> m = matrix.new<float>(2, 3, 1.5)
plot(matrix.get(m, 1, 2), "Last cell")

See also

Runs on Sidechair