使用findpeaks访问峰的宽度(信号包)

问题描述 投票:0回答:1

我正在使用位于信号包中的findpeaks function,我正在努力获得检测到的峰值的宽度。

从查看文档中可以看出:

“根”横坐标适合每个返回峰的横坐标值(以指数单位表示)与“基线”值相交。峰的宽度由diff(根)计算。

此函数接受以下列表中给出的属性 - 值对...

我从findpeaks获得了结构,这是我的输出:

ans =

  scalar structure containing the fields:

    parabol =

      scalar structure containing the fields:

        x =

           91
           95
    pp =

      -3.1387e+004  5.8853e+006  -1.6238e+008


height =   1.1352e+008
baseline =   6.6495e+007
roots =

   132.461    55.050

所以我相信roots对象为我提供了峰值的宽度,但是如何将这些数据输出到另一个变量?

octave
1个回答
1
投票

据我了解文档,您必须使用3个输出参数调用findpeaks

[pks,loc,extra] = findpeaks(...)

第一个峰的横坐标值(以索引单位表示)在变量extra.roots(1,:)中,因此宽度为:

width = extra.roots(1,1) - extra.roots(1,2)

这是一个例子:

t = 2*pi*linspace(0,1,1024)';
y = sin(3.14*t) + 0.5*cos(6.09*t) + 0.1*sin(10.11*t+1/6) + 0.1*sin(15.3*t+1/3);
figure,plot(data1)
hold on
plot(extra.roots(1,:),[0,0],'r','linewidth',10)

该示例将第一个峰的宽度显示为x轴上的红色条带。

如果你想知道变量t单位的宽度,那么你应该像这样缩放它:

width = (extra.roots(1,1) - extra.roots(1,2)) * (t(2)-t(1))

我希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.