Split matrix into unique bins, find max in each bin
显示 更早的评论
Hi all, I have a question regarding splitting a matrix into unique bins, and then finding the absolute maximum in each bin.
My data looks like the following, except larger by several orders of magnitude:
-50 -51 -53 -50 -60 -68 -65 -40 -42 -48 -52
0 0 0 0 1 1 1 0 0 0 0
As you can see, I have two sequences of zeros, and one sequence of ones. What I find to write is something that returns the min and max values in each of these sequences ie. -53 and -50 for the first sequence, -60 and -68 for the second, and -40 and -52 for the third. I haven't been able to do this with just indexing commands yet. I have been thinking about splitting these into bins, where each sequence is marked with a unique flag, and then finding the min and max in each bin, but I'm not sure how to accomplish this either.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!