Identifying minima that have no maximum above threshold between them

2 ビュー (過去 30 日間)
Alekhya Hati
Alekhya Hati 2022 年 10 月 31 日
コメント済み: Dyuman Joshi 2022 年 11 月 1 日
Using islocalmin() and islocalmax(), I get a logical array containing the information of minima and maxima of an oscillating data structure (curvature of a contour). Now I define two other logical arrays that provide location of curvatures above a threshold. Multiplying it with the min and max arrays, I get information on minima and maxima above the threshold.
But I end up with minima where between two minima there is no maximum above threshold. I want to identify such minima and set the minimum having lower magnitude to zero, so that between two minima I have atleast one maximum value.
Once I do this, between two minima, I identify all maxima and select the one having the highest value. This way I finally have an array containing information of oscillating minima and maxima (one minimum then next maximum, the next minimum, and so on).
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2022 年 11 月 1 日
%Random data
y=[1 2 4 2 5 8 3 7 1 4 1 5 3];
thmax=6;
thmin=3;
imax=find(islocalmax(y)&(y>thmax))
imax = 1×2
6 8
imin=find(islocalmin(y)&(y<thmin))
imin = 1×3
4 9 11
%there is no maxima above the threshold between minima at 9th and 11th index
for n=1:numel(imin)-1
if (imin(n)<imax)&(imin(n+1)>imax)
y(imin)=0;
end
end
y
y = 1×13
1 2 4 0 5 8 3 7 0 4 0 5 3

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by