Find the maximum value corresponding to the specific index

조회 수: 1 (최근 30일)
soe thiha
soe thiha 2020년 9월 28일
댓글: soe thiha 2020년 9월 28일
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