Replacing a LOT of data by zero (in a matrix)
Show older comments
I have a matrix M1, below you see the whos information for that matrix:
Name Size Bytes Class Attributes M1 29624x29624 108387640 double sparse
I want to replace quite a bit of data by zeros, using logical indexing: M1(abs(M1)<1e-1) = 0;
This needs more than 16GB memory, there must be a more efficient way. I also tried the other way round, that is M1 = M1(abs(M1)>1e-1);
Same problem. What's the trick?
Accepted Answer
More Answers (1)
Dmitry Borovoy
on 31 Aug 2011
0 votes
1 way. Use vectorization (your way). fast but requires a lot of RAM 2 way. Use loops. Very slow but no need a lot of RAM 3 way. For perverts. Write your code on C/C++/Fortran with loop and call it from Matlab. If you have restriction on RAM or on calculation speed, I suppose, it's your way.
1 Comment
Herwig Peters
on 31 Aug 2011
Categories
Find more on Matrix Indexing 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!