Find the maximum value corresponding to the specific index

1 次查看(过去 30 天)
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,

采纳的回答

David Hill
David Hill 2020-9-28
Assuming a two column matrix
maX= max(yourMatrix(yourMatrix(:,1)==1,2));
  3 个评论
David Hill
David Hill 2020-9-28
If you know the indexing:
maX = max(yourMatrix([2:5,10:11,13:14],2));
soe thiha
soe thiha 2020-9-28
Dear Mr David
Thank you very much for your help and advice.
It helps me a lot.
Regards,

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by