creating a temporary variable
Show older comments
This is a quick question. Compare
A = sparse(...); B = A - C;
and
B = sparse(...) - C;
Memory-wise spoken, is there a difference? Will the second one use less memory because I'm not creating a variable?
Accepted Answer
More Answers (1)
Nicholas
on 3 Jan 2012
Did you try using tic toc?
tic
A = sparse(magic(3));
B = A - C;
disp(toc)
tic
B = sparse(magic(3)) - C;
disp(toc)
In any case the result depends on matrix dimensions and matrix initialization. If you want to improve memory management you should initialize a matrix/vector first and than try to improve matrix calculation.
Categories
Find more on Loops and Conditional Statements 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!