matrix set-col

For filters.

Replace a column in a 2D matrix.

Command Type

built-in

Signature

> matrix set-col {flags} (index) (replacement)

Parameters

  • index: The column index to replace (0-based).
  • replacement: The new column values as a list of numbers.

Input/output types:

input output
matrix matrix

Examples

Replace the first column of a 2x3 matrix

> matrix zeros 2 3 | matrix set-col 0 [1.0 2.0] | matrix into-nu | to nuon
[[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]]

Replace the second column of a 2x2 matrix

> matrix zeros 2 2 | matrix set-col 1 [4.0 5.0] | matrix into-nu | to nuon
[[0.0, 4.0], [0.0, 5.0]]

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.