Is there another way to use mat2cell more efficiently when facing large matrices?
Afficher commentaires plus anciens
My project right now need to handle extreme size matrices. But I need to split them into equal sizes matrices in terms of a cell column for further calculation.
Right now my method of approach:
Assume A1 is the targeted matrix, where A1= 192x8
If I need to split it into each 8x8 matrix, well 192/8 = 24 cells.
My working on this matter:
d = mat2cell(A1U,[N N N N N N N N N N N N N N N N N N N N N N N N],N) %where N = 8
d = 24x1 cell group
{8×8 double}
{8×8 double}
{8×8 double} ..... total of 24
Although right now I can still handle these kind of sizes, but my target was a 1474560 x 64 matrix.
If so then I need to type 1474560 / 64 = 23040 times of N in the equation.
Is there a better way to tackle this problem?
1 commentaire
Moses Tang
le 28 Fév 2019
Réponse acceptée
Plus de réponses (1)
Guillaume
le 28 Fév 2019
If so then I need to type 1474560 / 64 = 23040 times of N in the equation.
Of course not! And you never had to type N more than once:
N = 8
numblocks = 64
d = mat2cell(A, repelem(N, numblocks), N)
Note that if you have the image processing toolbox, you could use blockproc to do the splitting and looping for you.
It may also be that you don't need to use a cell array at all (there's a fair bit of memory and speed overhead with cell arrays). Madhan's suggestion of using ND arrays is one way, or just looping over the indices in steps of 8.
1 commentaire
Moses Tang
le 28 Fév 2019
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!