Inserts an array as a new column of a matrix, at the end unless you give a position.
The array supplies the new column's items and needs as many items as the matrix has rows. Columns from the chosen position rightward move one place. Leave out column to append.
On an empty matrix the array's length decides the row count, so a matrix can be built from series one column at a time.
Syntax
matrix.add_col(id: any matrix type, column: series int (optional), array_id: any array type) -> void
matrix.add_col(column: series int (optional), array_id: any array type) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix that receives the new column. Its column count grows by one. |
| column | series int | the end of the matrix | Index of the column. Counts from 0. |
| array_id | any array type | required | The array whose items become the new row or column. |
Returns
Nothing.
Example
//@version=6
indicator("matrix.add_col: bias column", overlay = false)
matrix<float> m = matrix.new<float>(3, 2, 0.0)
matrix.add_col(m, matrix.columns(m), array.from(1.0, 1.0, 1.0))
plot(matrix.columns(m), "Columns")See also
Runs on Sidechair