sparse cell array?

조회 수: 10 (최근 30일)
Adam Craig
Adam Craig 2018년 7월 9일
답변: James Tursa 2018년 7월 9일
i have a cell array where the cells contain matrices. i need to preallocate it for efficiency.
it has to be a cell array because i need to assign matrices in blocks.
but the cell array is huge... upwards of 30,000x30,000 with 10x10 matrices in diagonal and off diagonal cells (and at the corners).
once the matrices are assigned, i use a simple indexing routine to assign to assign all the elements to a sparse matrix of complex numbers.
while the final matrix is < 1 gb, the problem is that it requires ~10 gb of memory to assign the cell array in the first place...
is there a way to preallocate a sparse cell array?
thanks guys :D

답변 (1개)

James Tursa
James Tursa 2018년 7월 9일
If you mean can the cell array itself be sparse, the answer is no to that as MATLAB only supports sparse double and logical. What you could do is maintain the cell array as a simple linear array, and then keep track of the indexing yourself off to the side. E.g., with row & column number indexing arrays, or perhaps employing a sparse logical matrix to implicitly keep the indexing.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by