Why am I unable to use linear indexing with sparse matrices when the sparse matrix is of size larger than the maximum array size in MATLAB 7.0 (R14) and later?

1 visualización (últimos 30 días)
I have following code:
D = sparse(756123, 769768);
i=756123;
j=769768;
D(i,j)=1;
a=D(i,j)
ind=sub2ind(size(D),i,j);
If I access the (756123, 769768)th element of "D" using linear indexing ( D(ind) ), I receive the following error:
ERROR: ??? Maximum variable size allowed by the program is exceeded.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 25 de Mzo. de 2023
Editada: MathWorks Support Team el 27 de Mzo. de 2023
This error is generated because of the way MATLAB 7.0 (R14) and later versions detect potential memory problems when creating and accessing elements of large sparse matrices.
When the size of the sparse matrix is larger than this limitation, MATLAB generates this error when attempting to access, using linear indexing, elements of sparse matrices that have a linear index larger than 2^31-1, disregarding the fact that the matrix is sparse.
To workaround this issue, use matrix indexing, D(i,j), to access elements of the sparse matrix with a linear index larger than 2^31-1.
See the solution below for a discussion of the limitations on the size of the largest matrix that you can create in MATLAB.

Más respuestas (0)

Categorías

Más información sobre Sparse Matrices en Help Center y File Exchange.

Productos


Versión

R14SP2

Community Treasure Hunt

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

Start Hunting!

Translated by