python - Python 中的方程式

标签 python numpy plot

我正在尝试用 Python 实现一篇论文中的方程(黑色方方程)-

enter image description here

到目前为止,我有一个简化的模型,但我无法生成预期的输出(下图);我怀疑问题出在 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()

enter image description here

最佳答案

为了说明 Jacob 的评论,这里是您可以通过调整常量得到的结果:

Graph

代码:

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/

相关文章:

Python ftplib 超时

python - 用于基于函数的 View 的 Django Rest Framework

python - 为什么 NumPy 在一个大矩阵 $M$ 上的减法比将 $M$ 分成较小的矩阵然后进行减法慢?

python - 如何在 python 中从 ndarray 中选择 n 项并跳过 m?

python - 列表(numpy.array)缓慢的原因是什么?

r - 在 x 轴刻度上添加 latex 表达式 @ggplot2

r - 将带有多个换行符和斜体字的文本添加到 R 中的绘图中

用于确定可用空间的 Python 脚本提供的结果不准确