How can I pre allocate the memory for a variable? or is it possible?
Show older comments
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
Accepted Answer
More Answers (2)
Iain
on 26 Feb 2014
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.
1 Comment
Metin Ertas
on 26 Feb 2014
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!