I'm implementing a simple FEA code and I need to zero out particular rows and columns to apply boundary conditions. Example matrix:
我正在实现一个简单的FEA代码,我需要将特定的行和列清零以应用边界条件。示例矩阵:
I tried with my_matrix[:,1] = 0
but it returns an error: ValueError: unexpected value: 0
我尝试使用my_matrix [:,1] = 0但它返回一个错误:ValueError:意外值:0
Can some one guide me on how to make columns and rows zero?
有人可以指导我如何使列和行为零吗?
1 个解决方案
#1
2
Sympy matrix objects don't appear to support assigning a constant to multiple entries like numpy array objects.
Sympy矩阵对象似乎不支持为多个条目(如numpy数组对象)分配常量。
Try my_matrix[:,1] = [0]*my_matrix.shape[0]
instead, which generates a list of 0
s of length equal to the number of rows of my_matrix
.
请尝试my_matrix [:,1] = [0] * my_matrix.shape [0],它会生成一个0的列表,其长度等于my_matrix的行数。
#1
2
Sympy matrix objects don't appear to support assigning a constant to multiple entries like numpy array objects.
Sympy矩阵对象似乎不支持为多个条目(如numpy数组对象)分配常量。
Try my_matrix[:,1] = [0]*my_matrix.shape[0]
instead, which generates a list of 0
s of length equal to the number of rows of my_matrix
.
请尝试my_matrix [:,1] = [0] * my_matrix.shape [0],它会生成一个0的列表,其长度等于my_matrix的行数。