在 python 中使用 FindPeaks 后如何从信号中提取最大值和最小值
使用下面的示例,如何将标记为“顶部”和“底部”的最大值和最小值拉入单独的数组中?
# Load library
import numpy as np
from findpeaks import findpeaks
# Data
i = 10000
xs = np.linspace(0,3.7*np.pi,i)
X = (0.3*np.sin(xs) + np.sin(1.3 * xs) + 0.9 * np.sin(4.2 * xs) + 0.06 * np.random.randn(i))
# Initialize
fp = findpeaks(method='peakdetect')
results = fp.fit(X)
# Plot
fp.plot1d()
Using the example below, how can I pull the max and min values marked as 'Top' and 'Bottom' into a separate array?
# Load library
import numpy as np
from findpeaks import findpeaks
# Data
i = 10000
xs = np.linspace(0,3.7*np.pi,i)
X = (0.3*np.sin(xs) + np.sin(1.3 * xs) + 0.9 * np.sin(4.2 * xs) + 0.06 * np.random.randn(i))
# Initialize
fp = findpeaks(method='peakdetect')
results = fp.fit(X)
# Plot
fp.plot1d()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您使用的是 findpeaks 库 2.4.0。
results
变量已包含min
和max
值。您可以通过以下方式获取:I assume you're using the findpeaks library 2.4.0. The
results
variable already contains themin
andmax
value. You can get it as follows: