Identifying minima that have no maximum above threshold between them
조회 수: 2 (최근 30일)
이전 댓글 표시
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
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))
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
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!