Split matrix into unique bins, find max in each bin
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!