フィルターのクリア

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
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.
MA
MA 2021 年 9 月 13 日
thank you for replying back. if the goal was only accessing the submatrix I would do what you siad. but each submatrix represent a set of data for a spicific interval of time. and as a matter of organizing data and labeling them, we need to extract those submatrices and get them labeled for future use and then store them inedependently in some way for future use. I hope you have an effecient way to do that.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 13 日
In the case where the indices indicate the beginnings of the new blocks:
TheMatrix = randi(9, 15, 2)
TheMatrix = 15×2
1 4 6 5 3 8 9 4 4 2 8 6 9 5 7 2 5 6 4 5
split_indices = sort(1 + randperm(14,2)) %beginnings of blocks
split_indices = 1×2
3 6
blk = diff([1 reshape(split_indices, 1, []) size(TheMatrix,1)+1]);
splits = mat2cell(TheMatrix, blk, size(TheMatrix,2))
splits = 3×1 cell array
{ 2×2 double} { 3×2 double} {10×2 double}
celldisp(splits)
splits{1} = 1 4 6 5 splits{2} = 3 8 9 4 4 2 splits{3} = 8 6 9 5 7 2 5 6 4 5 8 4 6 4 2 5 5 7 9 4
  3 件のコメント
Walter Roberson
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 .
MA
MA 2021 年 9 月 13 日
Thank you very much it worked perfectly, I really appreciate the help!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by