MATLAB: Creating a temporary variable

memory sparse

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?

Best Answer

There will be very little memory difference. For a transient value, MATLAB creates everything about the storage except the symbol table entry with the name and a pointer to the descriptor.