【发布时间】:2026-01-15 23:20:10
【问题描述】:
问题
我需要动画流畅,但它是逐帧绘制的。代码在 Jupyter Notebook 中运行。
这里是库
import numpy as np
from matplotlib import pyplot as plt
from scipy import signal as sp
创建要卷积的函数
t_ini=0
t_final = 11
dt=0.1
t = np.arange(t_ini,t_final,dt)
expo = np.exp(-t)*np.piecewise(t,t>=0,[1,0])
t1 = np.arange(0,10,0.1)
s = np.sin(t1)
conv_=sp.convolve(s,expo,'full')
n_conv=np.arange(min(t1)+min(t),max(t1)+max(t)+0.1,0.1)
y = [0] * len(conv_)
t2 = [0] * len(n_conv)
这是绘图
i = 0
for x in n_conv:
y[i] = conv_[i]
plt.cla()
t2[i] = n_conv[i]
plt.plot(t2,y)
plt.show()
plt.pause(0.5)
i = i+1
【问题讨论】:
标签: python python-3.x matplotlib scipy jupyter-notebook