简体   繁体   English

如何找到向量的相对最小值(不是最小值)

[英]How to find the relative minimums of a vector (not the minimum value)

Let's suposse I have a vector of values whose representation is the following one:让我们假设我有一个值向量,其表示如下:

在此处输入图片说明

The vector of data has 2000 elements and as you see, there is another vector with degrees between -180º and 180º.数据向量有 2000 个元素,如您所见,还有另一个度数介于 -180º 和 180º 之间的向量。 I'd like to find the indices of each minimum peak, but I don't know how to implement the algorithm.我想找到每个最小峰值的索引,但我不知道如何实现该算法。

In other cases, I set a threshold value (for example -75dBm) and considered a minimum any value under -75dBm, but in this case, there are peaks above -70dBm and I can't increase the threshold value since my measurements will be wrong.在其他情况下,我设置了一个阈值(例如 -75dBm)并考虑了低于 -75dBm 的最小值,但在这种情况下,峰值高于 -70dBm,我无法增加阈值,因为我的测量结果将是错误的。

I hope someone can help me.我希望有一个人可以帮助我。 Thank you for your responses.谢谢你的回复。

For data like this, your best bet is to smooth it and then use findpeaks.对于这样的数据,最好的办法是平滑它,然后使用 findpeaks。

For an example举个例子

%% 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM