友人をフロートだ、私は、Pythonに新たなんだとお互いに3つの曲線をプロットしようとしているが、私は理解することはできませんいくつかの問題を抱えて:Pythonの例外TypeError:予想レンジ()整数エンド引数は、
を私は別のベクトルでボールの軌道を解決しよう:
の1-異なるxは 、3-異なる角度が
import numpy as np
import math as m
import matplotlib.pylab as pl
def ball(x, theta, v0, y0):
v0= v0/3.6
g = 9.81
theta = m.radians(theta)
return x * m.tan(theta) + y0\
- 1./(2.0 * v0 ** 2.0) * g * x**2.0/(m.cos(theta)**2)
x = np.linspace(0, 10, 100)
#part1
theta = 60
y0 = 1.0
v0= 15.0
y = ball(x, theta, v0, y0)
pl.plot(x, y)
#part2
theta = 60
y0 = 1.0
for v0 in range(10.0, 60.0, 10.0):
y2 = ball(x, theta, v0, y0)
pl.plot(x, y)
#part3
y0 = 1.0
for theta in range(0.0, 112.5, 22.5):
y3 = ball(x, theta, v0, y0)
pl.plot(x, y)
pl.plot(x, y, "r*")
pl.plot(x, y2, "bo")
pl.plot(x, y3, "y^")
pl.xlabel("X")
pl.ylabel("Y")
pl.legend(["x,y","x,y","x,y"])
pl.show()
値 2 - 異なる速度値を値に何が起こっているか私を助けてください?
は何がエラーメッセージに関する不明ですか?浮動小数点数を 'range()'関数に渡しています。代わりに整数で渡してください。 –
私の問題は私がフローティングを使うべきだということでした、今私はそれを使用する方法を知っています、 – Hitch