如何在MATLAB中区分双峰和单峰阵列? [英] How to differentiate between a double peak and a single peak array in MATLAB?

查看:455
本文介绍了如何在MATLAB中区分双峰和单峰阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何区分双峰和单峰阵列?

How to differentiate between a double peak and a single peak array?

如果数组代表一个双峰,如何找到两个峰之间的最小点?寻找最小点时,不应考虑峰外的最小点(左侧峰的左侧和右侧峰的右侧).

Also if the array represents a double peak, how to find the minimum point between two peaks? The minimum points outside of the peaks (left of left peak and right of right peak) should not be considered in finding the minimum point.

推荐答案

我发现 PEAKDET 函数非常可靠且快速,尽管它是基于循环的.它不需要对噪声数据进行预平滑处理,但可以找到差异大于参数delta的局部最大和最小极值.

I found PEAKDET function to be quite reliable and fast although it's loop based. It does not require pre-smoothing of noisy data, but finds local max and min extrema with difference larger than parameter delta.

由于PEAKDET从左到右运行,因此有时会错过右侧站点的峰值.为了避免它,我希望运行两次:

Since PEAKDET runs from left to right it sometime misses peaks on the right site. To avoid it I prefer to run it twice:

%# some data
n = 100;
x = linspace(0,3*pi,n);
y = sin(x) + rand(1,n)/5;

%# run peakdet twice left-to-right and right-to-left
delta = 0.5;
[ymaxtab, ymintab] = peakdet(y, delta, x);
[ymaxtab2, ymintab2] = peakdet(y(end:-1:1), delta, x(end:-1:1));
ymaxtab = unique([ymaxtab; ymaxtab2],'rows');
ymintab = unique([ymintab; ymintab2],'rows');

%# plot the curve and show extreme points based on number of peaks
plot(x,y)
hold on
if size(ymaxtab,1) == 2 && size(ymintab,1) == 1 %# if double peak
    plot(ymintab(:,1),ymintab(:,2),'r.','markersize',30)
elseif size(ymaxtab,1) == 1 && size(ymintab,1) == 0 %# if single peak
    plot(ymaxtab(:,1),ymaxtab(:,2),'r.','markersize',30)
else %# if more (or less)
    plot(ymintab(:,1),ymintab(:,2),'r.','markersize',30)
    plot(ymaxtab(:,1),ymaxtab(:,2),'r.','markersize',30)
end
hold off

这篇关于如何在MATLAB中区分双峰和单峰阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆