当前位置:   article > 正文

MATLAB - 查找数据峰值_matlab 寻找峰值

matlab 寻找峰值

语法如下:

pks = findpeaks(data)
[pks,locs] = findpeaks(data)
[pks,locs,w,p] = findpeaks(data)
[___] = findpeaks(data,x)
[___] = findpeaks(data,Fs)
[___] = findpeaks(___,Name,Value)
findpeaks(___)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

where,pks是峰值返回值,locs是数据索引

  • […] = FINDPEAKS(…,'MinPeakHeight',MPH) finds only those peaks that are greater than the minimum peak height, MPH. MPH is a real-valued scalar. The default value of MPH is -Inf.
  • […] = FINDPEAKS(…,'MinPeakProminence',MPP) finds peaks guaranteed to have a vertical drop of more than MPP from the peak on both sides without encountering either the end of the signal or a larger intervening peak. The default value of MPP is zero.
  • […] = FINDPEAKS(…,'Threshold',TH) finds peaks that are at least greater than both adjacent samples by the threshold, TH. TH is a real-valued scalar greater than or equal to zero. The default value of TH is zero.
  • FINDPEAKS(…,'WidthReference',WR) estimates the width of the peak as the distance between the points where the signal intercepts a horizontal reference line. The points are found by linear interpolation. The height of the line is selected using the criterion specified in WR:
  • MinPeakHeight(峰值最小幅度阈值):指定峰值的最小幅度。只有幅度大于等于该阈值的峰值才会被检测到。
  • MinPeakDistance(峰值最小间距):指定峰值之间的最小距离。只有相邻峰值之间的间距大于等于该值的峰值才会被检测到。
  • MinPeakWidth(峰值最小宽度):指定峰值的最小宽度。只有宽度大于等于该值的峰值才会被检测到。宽度是指峰值左右两侧陡峭部分的宽度。
  • MinPeakProminence(峰值最小显著度):指定峰值的最小显著度。显著度是指峰值相对于其邻近谷底的高度差。只有显著度大于等于该值的峰值才会被检测到。
% 创建一个简单的信号
x = [1, 4, 2, 6, 4, 8, 3, 1];

% 指定最小距离和最小幅度阈值
[pks, locs] = findpeaks(x, 'MinPeakDistance', 2, 'MinPeakHeight', 4);

% 输出峰值的幅度和位置
disp(pks); % 输出:[6, 8]
disp(locs); % 输出:[4, 6]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

应用案例:

对信号数据进行频域分析后,想提取指定幅值以上的峰值所对应倍频,以下图为例,提取幅值为0.1以上的倍频值,可通过关键字MinPeakProminence进行操作。
在这里插入图片描述在这里插入图片描述

实现代码如下:

 [pks, locs] = findpeaks(y,'MinPeakProminence',0.1)
 hold on
 plot(freq(locs)*60/rpm,y(locs),'o')
 xlabel("倍频")
 ylabel("幅值")
 plot([0,165],[0.1,0.1],'-.')
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

参考文献:

  • https://ww2.mathworks.cn/help/signal/ref/findpeaks.html?searchHighlight=findpeaks&s_tid=srchtitle_findpeaks_1
  • https://ww2.mathworks.cn/help/signal/ug/find-peaks-in-data.html?searchHighlight=findpeaks&s_tid=srchtitle_findpeaks_3
  • https://ww2.mathworks.cn/help/signal/ug/peak-analysis.html?searchHighlight=findpeaks&s_tid=srchtitle_findpeaks_7
  • https://ww2.mathworks.cn/help/signal/ug/determine-peak-widths.html?searchHighlight=findpeaks&s_tid=srchtitle_findpeaks_5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/509891
推荐阅读
相关标签
  

闽ICP备14008679号