MATLAB: Memory usage in sparse matrix

memorysparse

Hi, Sparse matrices store only the nonzero elements and their position indices. Using sparse matrices can significantly reduce the amount of memory required for data storage. But surprisingly I noticed that my computer runs out of memory when I try something like >>sparse(zeros(80000)) or a matrix having more elements.In zeros(), as there is no non-zero element, the sparse matrix should not have used any memory in this case at all! I would really appreciate if anyone can elucidate this issue… thanks.

Best Answer

Try just:
>> sparse(80000,80000)
to avoid the temporary allocation of a 80000^2 non-sparse zeros array.