gpt4 book ai didi

matlab - MATLAB 信号处理工具箱中函数 findpeaks 的意外行为

转载 作者:行者123 更新时间:2023-12-05 05:29:03 27 4
gpt4 key购买 nike

编辑:其实这不是意外行为,但我仍然需要一个解决方案。findpeaks 将数据的每个元素与其相邻值进行比较。

我的数据包含我用函数 findpeaks 检测到的峰来自信号处理工具箱。有时函数似乎无法正确检测到峰值,当我有两次相同的值时。这种情况在我的数据中很少发生,但这里有一个示例来说明我的问题:

>> values

values =

-0.0324
-0.0371
-0.0393
-0.0387
-0.0331
-0.0280
-0.0216
-0.0134
-0.0011
0.0098
0.0217
0.0352
0.0467
0.0548
0.0639
0.0740
0.0813
0.0858 <-- here should be another peak
0.0858 <--
0.0812
0.0719
0.0600
0.0473
0.0353
0.0239
0.0151
0.0083
0.0034
-0.0001
-0.0025
-0.0043
-0.0057
-0.0048
-0.0038
-0.0026
0.0007
0.0043
0.0062
0.0083
0.0106
0.0111
0.0116
0.0102
0.0089
0.0057
0.0025
-0.0025
-0.0056

现在 findpeaks 函数只能找到一个峰:

>> [pks loc] = findpeaks(values)

pks =

0.0116


loc =

42

如果我绘制数据,很明显 findpeaks 错过了位置 18/19 的一个峰值,因为它们的值都为 0.08579

alt text

找到那些缺失的峰的最佳方法是什么?

最佳答案

如果你有图像处理工具箱,你可以使用IMREGIONALMAX找到峰值,之后您可以使用 regionprops 找到区域的中心(如果这是您需要的),即

bw = imregionalmax(signal);
peakLocations = find(bw); %# returns n peaks for an n-tuple of max-values

stats = regionprops(bw,'Centroid');
peakLocations = cat(1,stats.Centroid); %# returns the center of the n-tuple of max-values

关于matlab - MATLAB 信号处理工具箱中函数 findpeaks 的意外行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4376636/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com