我在Python中有以下工作。我正在尝试使用Python求解方程,并通过绘制方程来显示结果。当我运行以下代码时,出现以下错误:
错误:
Traceback (most recent call last):
File "C:\Users\raineen\Desktop\Raneen_Python\Sigma_theta_c.py", line 44, in <module>
segma.append((((Tt*Ct[count])/(2*t0*lambda1))*((m.log(item*r))**Nt[count]))+(((Tb*Cb)/(2*t0*lambda1))*((m.log(item*r))**Nb))+((Tt*Ct[count])/(t0*lambda1*(Nt[count]+1)))*((m.log(item*r))**(Nt[count]+1)-(m.log(item*R0))**(Nt[count]+1))+ ((Tb*Cb)/(t0*lambda1*(Nb+1)))*((m.log(item*r))**(Nb+1)-(m.log(item*R0))**(Nb+1)))
IndexError: list index out of range
我有三个列表,我同时遍历它们,它们是:
t = [x/100 for x in range(1, 201)] # [0.01,0.02,0.02,..........,2]
Ct= [126.0, 127.82549463360013, 129.67743712955985, 131.55621066590138, 133.46220397215035, 135.39581140976628, 137.35743305373825, 139.34747477536274, 141.36634832622116, 143.41447142337327]
a= [39.960039960039964, 19.960079840319363, ..........]
请问我可以得到任何帮助来解决此问题吗?
Python
import math as m
import matplotlib.pyplot as plt
lambda1 = 1
t = [x/100 for x in range(1, 201)]
t0 = 2
Tt = 1.5
Kt = 126
Kb = 1261
Rt = 5
Nt = [x/10 for x in range(0, 10)]
Nb = 0.36
Tb = 0.5
r = 6.5
R0 = Rt + t0
z = 2/m.sqrt(3)
#Ct = Kt*(z**Nt)
Cb = Kb*(z**Nb)
print('t= ', t)
print('Nt= ', Nt)
Ct = []
for n in Nt:
Ct.append(Kt*(z**n))
Rm = []
for j in t:
Rm.append(5+(j/2))
print('Rm= ',Rm)
print('Ct= ',Ct)
a = []
for k,i in zip(Rm,t):
a.append(t0/(k*i))
print(k, i)
print('a= ',a)
segma = []
for count, item in enumerate(a):
segma.append((((Tt*Ct[count])/(2*t0*lambda1))*((m.log(item*r))**Nt[count]))+(((Tb*Cb)/(2*t0*lambda1))*((m.log(item*r))**Nb))+((Tt*Ct[count])/(t0*lambda1*(Nt[count]+1)))*((m.log(item*r))**(Nt[count]+1)-(m.log(item*R0))**(Nt[count]+1))+ ((Tb*Cb)/(t0*lambda1*(Nb+1)))*((m.log(item*r))**(Nb+1)-(m.log(item*R0))**(Nb+1)))
print('Sigma_theta_c = ', segma)
##for i in segma:
## print(i)
plt.plot(t,segma)
plt.xlabel('t')
plt.ylabel('Sigma_theta_c')
plt.show()
这在等式下方: