赞
踩
语法如下:
pks = findpeaks(data)
[pks,locs] = findpeaks(data)
[pks,locs,w,p] = findpeaks(data)
[___] = findpeaks(data,x)
[___] = findpeaks(data,Fs)
[___] = findpeaks(___,Name,Value)
findpeaks(___)
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]
应用案例:
对信号数据进行频域分析后,想提取指定幅值以上的峰值所对应倍频,以下图为例,提取幅值为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],'-.')
参考文献:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。