import numpy as np import matplotlib matplotlib.use("TKAgg") import matplotlib.pyplot as plt g=9.8 s=100 ds=0.00001 #单位米 v0=0.001 #m/s v=[v0] t=[ds/v0] t_sum=0 ds_num=int(s/ds) x=[] y=[] for i in range(ds_num+1): if i==0 : continue vi=v[i-1] + g * t[i-1] v.append(vi) ti=ds/vi t.append(ti) t_sum +=ti x.append(t_sum) y.append(ds * i) fig,ax=plt.subplots() x1=np.arange(0,np.sqrt(2*s/9.8),0.01) y1=0.5 * g * x1**2 ax.plot(x,y, color='green',linewidth=0.1) ax.plot(x1,y1, color='red', linewidth=0.1) print(np.sqrt(20/9.8)) plt.show()View Code
标签:python,vi,加速运动,matplotlib,np,ax,ds,append From: https://www.cnblogs.com/wdfrog/p/18013552