Find the maximum value corresponding to the specific index
1 view (last 30 days)
Show older comments
Dear Matlab Experts
I want to find the maximum values corresponding to the continuous 1 value groups. The data is like this format.
(1) continuous 1 value groups is found.
the code provided by Mr per isakson is like this. From the code, I got the start and end of index of continouos 1 values.
d = diff( c );
ixb = find( d == +1 ) + 1;
ixe = find( d == -1 );
%%
is_group = ixe >= ixb + 1;
[ ixb(is_group), ixe(is_group) ]
(2) I want to get is the corresponding maximum value among the continous 1 value groups. There are 3 continuous 1 values indexing from 2~5,10~11 and 13~14. The answer is 2234 which is within the second continuous 1 value groups 10~11.
Index Value
0 850
1 800
1 947
1 801
1 857
0 829
0 1569
1 2235
0 2169
1 2234
1 1557
0 962
1 838
1 774
If someone can help me on this task?
Thank you very much.
Best regards,
0 Comments
Accepted Answer
David Hill
on 28 Sep 2020
Assuming a two column matrix
maX= max(yourMatrix(yourMatrix(:,1)==1,2));
3 Comments
David Hill
on 28 Sep 2020
If you know the indexing:
maX = max(yourMatrix([2:5,10:11,13:14],2));
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!