How can I pre allocate the memory for a variable? or is it possible?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (2)
Azzi Abdelmalek
el 26 de Feb. de 2014
Sis=zeros(33489,5625)
1 comentario
Metin Ertas
el 26 de Feb. de 2014
Iain
el 26 de Feb. de 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 comentario
Metin Ertas
el 26 de Feb. de 2014
Categorías
Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!