Function Repository Resource:

PrependColumn

Source Notebook

Prepend a column to the left of a matrix

Contributed by: Michael Sollami

ResourceFunction["PrependColumn"][matrix,list]

prepends a vector list as a column to matrix.

ResourceFunction["PrependColumn"][matrix,s]

prepends a constant vector of scalar s to matrix.

ResourceFunction["PrependColumn"][column]

represents an operator form of PrependColumn that can be applied to a matrix.

Details and Options

Dimensions of matrix and list must be compatible.

Examples

Basic Examples (2) 

Prepend a column vector to a matrix:

In[1]:=
m = {{1, 1, 1}, {2, 2, 2}, {3, 3, 3}};
ResourceFunction["PrependColumn"][m, {2, 4, 6}] // MatrixForm
Out[2]=

Append a scalar value to a matrix:

In[3]:=
ResourceFunction["PrependColumn"][m, \[Pi]] // MatrixForm
Out[3]=

Scope (1) 

Use PrependColumn as an operator form:

In[4]:=
m = RandomReal[1, {3, 4}]; 
ResourceFunction["PrependColumn"][{1, 2, 3}]@m // MatrixForm
Out[4]=

Publisher

Michael Sollami

Version History

  • 1.0.0 – 23 March 2020

Related Resources

License Information