我想在numpy中构建一个矩阵。矩阵的尺寸应该是(5001x7)。这里是我的代码:构建一个numpy矩阵
S=np.array([.0788,.0455,.0222,.0042,.0035,.0029,.0007])
#This is vector S, comprised of 7 scalars.
lamb=list(range(0,5001))
#This is a list of possible values for lambda, a parameter in my data.
M = np.empty([5001,7], order='C')
#This is the empty matrix which is to be filled in the iterations below.
for i in S:
for j in lamb:
np.append(M,((S[i]**2)/(lamb[j]+S[i]**2)))
我遇到的问题是,M仍然是零矢量矩阵。
重要的细节: 1)我已经分配最后的路线为:
M=np.append(M,((S[i]**2)/(lamb[j]+S[i]**2)))
我然后在一维数组得到长度70014的值的阵列。我不确定该怎么做。
2)我已经尝试了矩阵M.
3)I收到此警告切换“浮动”和“INT”之间的D型细胞参数,当我运行的代码: VisibleDeprecationWarning:使用非整数而不是整数会导致错误的未来 app.launch_new_instance()
4)我在Python 3.4
工作,我真的很感谢你的帮助。谢谢!
我不认为'np.append'是做什么的,你觉得它在做什么。 –