Sidechair

matrix.row()

Browse the reference

Returns one row of a matrix as a new array.

Try it in the editor

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

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

Arguments

NameTypeDefaultDescription
idany matrix typerequiredThe matrix to copy a row from. The matrix itself is not changed.
rowseries intrequiredIndex of the row. Counts from 0.

Returns

array<>: A new array with the row's items.

Example

Pine ScriptAverage of a rowOpen in editor
//@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