[英]How to find the relative minimums of a vector (not the minimum value)
对于这样的数据,最好的办法是平滑它,然后使用 findpeaks。
举个例子
%% parameters to adjsut
%smoothing window length
smthwin=50;
%minimum peak prominence
mpp=0.01;
%% create some test data
x=(1:1000)/1000;
y=sin(3*x-0.5).*sin(5*x).*sin(9*x-0.1).*sin(15*x-0.3)+rand(size(x))/10;
%% smooth and findpeaks
%smooth it
%here I use a median filter, but smooth() is a great function too with lots of options
ysmth=medfilt1(y,smthwin);
%use findpeaks on -y to find local minima
[pks,pks_loc]=findpeaks(-ysmth,'MinPeakProminence',mpp);
%the location of the local minima is
mins=x(pks_loc);
%%plot to check
figure
plot(x,y)
hold on
plot(mins,-pks,'o','LineWidth',2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.