How to release zero elements in sparse matrix
显示 更早的评论
Hi,
The Matlab document says sparse matrix does not release elements from memory when they are set to zero. Then how can I release the elements if they are zero?
For example:
>> a=sparse(ones(10,10));
>> nzmax(a)
ans =
100
>> a(1:5,1:5)=0;
>> nzmax(a)
ans =
100
>>
What I want is that nzmax(a) reports 75 since I don't want to waste the memory for 25 zeros. Is there any command I can use?
Thanks in advance!
Edit: Made the description of example clear.
采纳的回答
更多回答(2 个)
Walter Roberson
2013-2-7
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Sparse Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!