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?
2 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2009 年 6 月 27 日
編集済み: MathWorks Support Team
2023 年 3 月 27 日
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.
採用された回答
MathWorks Support Team
2023 年 3 月 25 日
編集済み: MathWorks Support Team
2023 年 3 月 27 日
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.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!