Returns the item in a given row and column of a matrix.
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
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
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to read an item from. The matrix itself is not changed. |
| row | series int | required | Index of the row. Counts from 0. |
| column | series int | required | Index of the column. Counts from 0. |
Returns
<matrix_type>: The item at that row and column.
Example
//@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