0
我是初學者,使用python。我有以下代碼:ValueError:使用序列符號設置數組元素
import Deformation
import Qtheta
import numpy as np
import sympy as sp
def champs_de_contraintes(epaisseurs,angles,El,Et,Glt,Nult):
E0=np.mat('[0;0;0]') #inizialising E0
K=np.mat('[0;0;0]') #inizialising K
E0K=np.mat('[0;0;0;0;0;0]') #inizialising K
E0K = Deformation.defos(epaisseurs,angles,El,Et,Glt,Nult) #function that return a 6x1 matrix type <class 'numpy.matrixlib.defmatrix.matrix'>
E0=E0K[:3] #Slicing E0K into 2 vectors E0 and K
K=E0K[3:]
nb_composantes = 3 #sigma x, sigma y, taux xy
Sigmaxy=np.zeros((nb_composantes,len(epaisseurs))) #sigma x, sigma y, taux xy, Array
#===============This bloc calculate the altitude of a ply =================
z=[]
e=[]
z.append(-(np.sum(epaisseurs))/2)
for k in (range(len(epaisseurs))): #initialising e[k]
e[len(e):] = [0] #Values to add to get the altitude
for i in (range(len(epaisseurs))):
e[i]= e[i-1] + epaisseurs[i] #sum e
z[len(z):] = [z[0] + e[i]] #Altitude
#===========================This bloc calculate a vector===================
for i in (range(len(epaisseurs))):
newcolumn= Qtheta.Qtheta(angles[i],El,Et,Glt,Nult)*E0+z[i]*Qtheta.Qtheta(angles[i],El,Et,Glt,Nult)*K #z is the altitude
#3x1 = 3x3*3x1 + 1x1*3x3*3x1
for m in (range(len(newcolumn))):
Sigmaxy[i,m]=newcolumn[m]
return Sigmaxy
這將返回我的錯誤
Sigmaxy[i,m]=newcolumn[m]
ValueError: setting an array element with a sequence
基本上,我想要做的是保存矢量「newcolumn」在Sigmaxy矩陣newcolumn。 我認爲我得到這個錯誤是因爲「newcolumn」是符號。實際上,E0和K取決於2個變量。
有人可以幫我這個嗎?
在此先感謝!