How can I pre allocate the memory for a variable? or is it possible?
古いコメントを表示
Assume that I have a variable "Sis" and it will be used as sparse matrix. and non zero elements will be set in the following loops. The problem is if you don't allocate the memory before you use, it takes really long time to create a matrix of (2.000.000, 250.000);
İs there a way to doing that
Sis 33489x5625 3970464 double sparse
Sis_2 33489x5625 1507005000 double
Here is an example to show why I need sparse matrix.
Thanks
採用された回答
その他の回答 (2 件)
Iain
2014 年 2 月 26 日
lf you want is to preallocate a sparse array, all you need is:
Sis = sparse(2000000, 250000);
If you look at the help documentation for the sparse function, you might be able to find a better way of doing what you're trying to do.
カテゴリ
ヘルプ センター および File Exchange で Sparse Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!