0
我试图编写一个程序,它将使用不同的方式(欧拉,Runge ...)集成一个函数并使用内置函数scipy.integrate.odeint。元组索引必须是整数不是元组,matplot
一切和我得到正确的结果,但我也需要创建一个图形的结果,这就是当一切都出错了。 对于odeint函数,我无法绘制图形。 这里是我的代码和错误,我希望有人能够帮助我。
def odeint(phi, t0tf, Y0, N):
T6=numpy.zeros((N+1))
T6[0]=t0tf[0]
h=(t0tf[1]-t0tf[0])/N
for i in range (N):
T6[i+1]=T6[i]+h
def f(t,x):
return phi(x,t)
Y6 = scipy.integrate.odeint(f,Y0,T6, full_output=True)
return Y6
Y6 = edo.odeint(phi, t0tf, Y0, N)
T6Y6 = numpy.hstack([Y6])
print("Solutions Scipy :")
print()
print(T6Y6)
print()
mpl.figure("Courbes")
mpl.plot(Y6[0:N,0],Y6[0:N,1],color="yellow",label="Isoda")
mpl.show()
和错误是:提前
mpl.plot(Y6[0:N,0],Y6[0:N,1],color="yellow",label="Isoda")
TypeError: tuple indices must be integers, not tuple
感谢(PS:我是法国人,所以我的句子可能是有点不稳)
你能否包括完整的回溯,并包含足够的信息,我们可以复制粘贴 - 运行你的例子? – tacaswell