Identifying minima that have no maximum above threshold between them

8 views (last 30 days)
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 Comment
Dyuman Joshi
Dyuman Joshi on 1 Nov 2022
%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

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!