I'm trying to optimize some code for memory use and I'm wondering if the varargout variable makes a copy of the variables which are assigned to it. For example:
function varargout = foo(bar)C={rand(bar,bar^2,bar^3), false(100,100,100))};varargout(1:nargout)=C(1:nargout);end
If bar is a big number than C will be huge and if a copy needs to be made at any stage an out of memory error may occur. My gut tells me no copy is made but I can't seem to find an explicit answer.
Best Answer