how to break up a huge matrix at a specific different rows breakpoints into several smaller matrices
2 views (last 30 days)
Show older comments
I have a huge matrix that I need to sort and break up into smaller matrices, now given that we know the indcies of the rows where we should split the matrix and we alrady have these indecies stored somewhere in another matrix how can we break the matrix effeciently at those specific breakpoints into several smaller matrices?
Accepted Answer
Walter Roberson
on 13 Sep 2021
In the case where the indices indicate the beginnings of the new blocks:
TheMatrix = randi(9, 15, 2)
split_indices = sort(1 + randperm(14,2)) %beginnings of blocks
blk = diff([1 reshape(split_indices, 1, []) size(TheMatrix,1)+1]);
splits = mat2cell(TheMatrix, blk, size(TheMatrix,2))
celldisp(splits)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!