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,
0 件のコメント
採用された回答
David Hill
2020 年 9 月 28 日
Assuming a two column matrix
maX= max(yourMatrix(yourMatrix(:,1)==1,2));
3 件のコメント
David Hill
2020 年 9 月 28 日
If you know the indexing:
maX = max(yourMatrix([2:5,10:11,13:14],2));
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!