0
我正在Python中使用for循环运行50多个迭代的模型,并且想要在25次迭代之后绘制它,并且在50次迭代之后再次绘制它。通过for循环中途绘制东西 - python
下面是我迄今为止使用的代码的摘录(如果这会有帮助,我可以发布整个事情)。
ts = np.array([0])
xs = f(ts)
for i in range(50):
tn = ts[i]+0.1
xn = f(tn)
ts = np.append(ts,tn)
xs = np.append(xs,xn)
while i == 24:
plt.plot(ts,xs)
plt.savefig('Weight plotted after 2.5 seconds.png')
while i == 49:
plt.plot(ts,xs)
plt.savefig('Spring plotted after 5 seconds.png')
我没有得到任何错误,但它只是没有返回任何东西。我对python和编码通常很陌生,所以任何人都可能会有什么输入将会非常感谢!
啊,这应该是显而易见的...感谢您的帮助,我在那里工作! – Alpacaheaven