Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Call by reference / references
Date: Fri, 5 Mar 2010 15:51:21 +0000 (UTC)
Organization: Xoran Technologies
Lines: 22
Message-ID: <hmr99p$35t$1@fred.mathworks.com>
References: <fgv1uh$hj2$1@fred.mathworks.com> <muy4pfwlrvb.fsf@G99-Boettcher.llan.ll.mit.edu> <MPG.219e667db96ef9889897e6@news.mathworks.com> <hmr6ut$2fg$1@fred.mathworks.com> <hmr8ds$7uh$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1267804281 3261 172.30.248.37 (5 Mar 2010 15:51:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 5 Mar 2010 15:51:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:614196

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hmr8ds$7uh$1@fred.mathworks.com>...

> 
> function test(ob)
> 
>  ob.data=cellfun(@(a)2*a, ob.data,'uni',0); %double all cell elements
> 
> end

Sorry, bad example. You would need to implement test.m this way, to avoid a complete new copy of ob.data inside its workspace

 function test(ob)

  for ii=1:length(ob.data)
 
      ob.data{ii}=ob.data{ii}*2;
     
  end

end

Anyway, the point is, the copy of ob.data being manipulated inside test.m is exactly the one in your base workspace. So, you wouldn't get an out-of-memory error in larger sized examples.