小编Jug*_*ksi的帖子

Python中的峰值检测算法

我正在 Python 中实现峰值检测算法,该算法仅检测高于阈值幅度的峰值。我不想使用内置函数,因为我还必须将此模拟扩展到硬件实现。

from math import sin,isnan
from pylab import *

def peakdet(v, delta,thresh,x):
    delta=abs(delta)
    maxtab = []
    mintab = []

    v = asarray(v)

    mn, mx = v[0], v[0]
    mnpos, mxpos = NaN, NaN

    lookformax = True

    for i in arange(len(v)):
        this = v[i]
        if abs(this)>thresh:
            if this > mx:
                mx = this
                mxpos = x[i]
            if this < mn:
                mn = this
                mnpos = x[i]
            if lookformax:
                if (this < mx-delta):
                    if (mx>abs(thresh)) and not isnan(mxpos):
                        maxtab.append((mxpos, mx))
                    mn …
Run Code Online (Sandbox Code Playgroud)

python function detect detection

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

detect ×1

detection ×1

function ×1

python ×1