how to break up a huge matrix at a specific different rows breakpoints into several smaller matrices
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 4
Chunru
2021년 9월 13일
For the sake of saving space of the large matrix, try to directly access to the submatrix, instead of reproducing the submatrices, if it is possible.
채택된 답변
Walter Roberson
2021년 9월 13일
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)
댓글 수: 3
Walter Roberson
2021년 9월 13일
In your actual code, make split_indices the indices of the starts of each new section. Do not include index 1 or the index of the end of the block, just the internal indices. Then use the assignment to blk and the assignment to splits .
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!