Find the maximum value corresponding to the specific index

1 Ansicht (letzte 30 Tage)
soe thiha
soe thiha am 28 Sep. 2020
Kommentiert: soe thiha am 28 Sep. 2020
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,

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by