Sidechair

matrix.col()

Browse the reference

Returns one column of a matrix as a new array.

Try it in the editor

The array lists the column's items from the first row down. It is a copy, so edits to the array do not reach the matrix.

Use it to take one variable out of a table of observations, such as the third series in a set of columns.

Syntax

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

Arguments

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

Returns

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

Example

Pine ScriptLargest in a columnOpen in editor
//@version=6
indicator("matrix.col: column max", overlay = false)
matrix<float> m = matrix.new<float>(3, 2, 1.0)
matrix.set(m, 2, 1, 9.0)
plot(array.max(matrix.col(m, 1)), "Max of column 1")

See also

Runs on Sidechair