我正在尝试用 Python 实现一篇论文中的方程(黑色方方程)-
到目前为止,我有一个简化的模型,但我无法生成预期的输出(下图);我怀疑问题出在 np.exp() 上尽管我不确定 - 关于如何执行此操作的任何建议?
import numpy as np
import math
import matplotlib.pyplot as plt
f = 1e6
T = 1/f
Omega = 2*np.pi*f
i = np.arange(0,50e-6,100e-9)
y = np.sin(Omega*i) * (i**2) * np.exp(-i)
plt.figure(1)
plt.plot(i,y,'b-')
plt.grid()
plt.show()
最佳答案
为了说明 Jacob 的评论,这里是您可以通过调整常量得到的结果:
代码:
import numpy as np
import matplotlib.pyplot as plt
f = 5
Omega = 2*np.pi*f
i = np.arange(0, 10, 0.001)
y = np.sin(Omega*i) * (i**2) * np.exp(-i)
plt.figure(1)
plt.plot(i,y,'b-')
plt.grid()
plt.show()
或者,您可以保持时间尺度并引入一个大约 5e-6 的 h,正如 Bas Swinckels 在他的回答中建议的那样:
f = 1e6
Omega = 2*np.pi*f
i = np.arange(0,50e-6,100e-9)
y = np.sin(Omega*i) * (i**2) * np.exp(-i/5e-6)
这会产生非常相似的输出。
关于python - Python 中的方程式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19624104/