sympy.Matrix().col_insert()
借助Matrix().col_insert()方法,我们可以在一个维度为nxm的矩阵中插入一列,其中插入列的维度为nx1。
语法: Matrix().col_insert()
返回:返回一个新的矩阵。
sympy.Matrix().col_insert() 例# 1:
在这个例子中,我们能够通过使用matrix ().col_insert()方法在矩阵中插入一列。
# Import all the methods from sympy
from sympy import *
# Make a matrix
gfg_mat = Matrix([[1, 2], [2, 1]])
# use the col_insert() method for matrix
new_mat = gfg_mat.col_insert(1, Matrix([[3], [4]]))
print(new_mat)
Output :
Matrix([[1, 3, 2], [2, 4, 1]])
sympy.Matrix().col_insert() 例# 2:
# Import all the methods from sympy
from sympy import *
# Make a matrix
gfg_mat = Matrix([[1, 2], [2, 1]])
# use the col_insert() method for matrix
new_mat = gfg_mat.col_insert(2, Matrix([[13], [24]]))
print(new_mat)
Output :
Matrix([[1, 2, 13], [2, 1, 24]])