Returns one row of a matrix as a new array.
The array holds the row's items from the first column to the last. It is a copy: changing the array leaves the matrix alone.
Combine it with the array statistics to summarise a row, for example array.avg(matrix.row(m, 0)).
Syntax
matrix.row(id: any matrix type, row: series int) -> array<>
matrix.row(row: series int) -> array<>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to copy a row from. The matrix itself is not changed. |
| row | series int | required | Index of the row. Counts from 0. |
Returns
array<>: A new array with the row's items.
Example
//@version=6
indicator("matrix.row: row mean", overlay = false)
matrix<float> m = matrix.new<float>(2, 3, 4.0)
matrix.set(m, 0, 0, 1.0)
plot(array.avg(matrix.row(m, 0)), "Mean of row 0")See also
Runs on Sidechair