📜  Python| sympy.Matrix().col_insert()

📅  最后修改于: 2022-05-13 01:54:38.421000             🧑  作者: Mango

Python| sympy.Matrix().col_insert()

借助Matrix().col_insert()方法,我们可以在维度为 nxm 的矩阵中插入一列,其中插入列的维度为 nx1。

示例 #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)

输出 :

示例 #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)

输出 :