Identifying minima that have no maximum above threshold between them
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Dyuman Joshi
il 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))
imin=find(islocalmin(y)&(y<thmin))
%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
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!