Returns a new matrix holding a block of an existing one.
The block runs from from_row up to, but not including, to_row, and the same for columns. Left out, the range covers the whole matrix, so the call is a full copy.
The result is a separate matrix; changing it does not change the source.
Syntax
matrix.submatrix(id: any matrix type, from_row: series int (optional), to_row: series int (optional), from_column: series int (optional), to_column: series int (optional)) -> matrix<>
matrix.submatrix(from_row: series int (optional), to_row: series int (optional), from_column: series int (optional), to_column: series int (optional)) -> matrix<>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to cut a block from. The block is returned as a new matrix. |
| from_row | series int | 0 | First row of the range. Counts from 0. |
| to_row | series int | the number of rows | Row just after the last row of the range. |
| from_column | series int | 0 | First column of the range. Counts from 0. |
| to_column | series int | the number of columns | Column just after the last column of the range. |
Returns
matrix<>: A new matrix with the selected rows and columns.
Example
//@version=6
indicator("matrix.submatrix: corner", overlay = false)
matrix<float> m = matrix.new<float>(3, 3, 5.0)
corner = matrix.submatrix(m, 0, 2, 0, 2)
plot(matrix.rows(corner), "Rows in block")See also
Runs on Sidechair