Returns one column of a matrix as a new array.
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
matrix.col(id: any matrix type, column: series int) -> array<>
matrix.col(column: series int) -> array<>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to copy a column from. The matrix itself is not changed. |
| column | series int | required | Index of the column. Counts from 0. |
Returns
array<>: A new array with the column's items.
Example
//@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