Identifying minima that have no maximum above threshold between them

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

%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개)

카테고리

도움말 센터File Exchange에서 Industrial Statistics에 대해 자세히 알아보기

태그

질문:

2022년 10월 31일

댓글:

2022년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by