这是我的脚本,它用于绘制张力平方与距离平方的倒数的函数曲线:import numpy as npimport matplotlib.pyplot as pltplt.title(\'Courbe de la
这是我的脚本,用于绘制张力平方与距离平方的倒数的关系曲线:
import numpy as np
import matplotlib.pyplot as plt
plt.title("Courbe de la tension en fonction de la distance à l'émeteur")
d = [0.1,0.12,0.15,0.2,0.25,0.3,0.4]
A = []
for n in range (len(d)):
A.append (1/(d[n]**2))
U = [0.456,0.340,0.304,0.224,0.172,0.152,0.116]
B = [ ]
for n in range (len(U)):
B.append (U[n]**2)
plt.plot(B, A)
plt.xlabel("inverse de la distance en m au carré")
plt.ylabel("tension au carrée")
modele= np.polyfit(A,B,1)
plt.plot(A, modele[0]*A + modele[1])
plt.show()
这是错误:
Traceback (most recent call last):
File "<module1>", line 23, in <module>
TypeError: can't multiply sequence by non-int of type 'numpy.float64'
>>>