Stores a value in a given row and column of a matrix.
matrix.set(m, 1, 0, 5.0) overwrites the second row's first item. The cell has to exist already; grow the matrix with matrix.add_row() or matrix.add_col() first.
The value must match the matrix's element type.
Syntax
matrix.set(id: any matrix type, row: series int, column: series int, value: series <type of the matrix's elements>) -> void
matrix.set(row: series int, column: series int, value: series <type of the matrix's elements>) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to write into. Only the item at the chosen row and column is replaced. |
| row | series int | required | Index of the row. Counts from 0. |
| column | series int | required | Index of the column. Counts from 0. |
| value | series <type of the matrix's elements> | required | The value to store. It has to match the type of the matrix's elements. |
Returns
Nothing.
Example
//@version=6
indicator("matrix.set: diagonal", overlay = false)
matrix<float> m = matrix.new<float>(2, 2, 0.0)
matrix.set(m, 0, 0, close)
matrix.set(m, 1, 1, open)
plot(matrix.trace(m), "Open plus close")See also
Runs on Sidechair