Path: news.mathworks.com!not-for-mail
From: "Stuart McGarrity" <stuart.mcgarrity.nospam@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: call by reference
Date: Sat, 12 Apr 2008 19:10:06 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 49
Message-ID: <ftr1ee$6cf$1@fred.mathworks.com>
References: <8902033.1207992837734.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Stuart McGarrity" <stuart.mcgarrity.nospam@mathworks.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1208027406 6543 172.30.248.37 (12 Apr 2008 19:10:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 12 Apr 2008 19:10:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 512264
Xref: news.mathworks.com comp.soft-sys.matlab:462611



Jeroen <jverhoeve@hotmail.com> wrote in message 
<8902033.1207992837734.JavaMail.jakarta@nitrogen.mathforum.
org>...
> Hi all,
> 
> For some GPS related calculations, I have a bunch of 
vectors  and variables which are needed in a lot of 
functions.
> 
> The thing is that all those date belong togehter in some 
way. When I would program in Jave, I would make a class 
from it.
> 
> So, what I did is making a new matlab data type which 
bundles all this information. I added some functions such 
that it acts just as a struct: I can acces the columns and 
the elements. The nice advantage is that I could modify 
the display function, such that I get a nice overview of 
the data when omitting the ;
> 
> But, when I pass this data type as argument to a 
function, do some manipulations on it, and want the 
function to return it, it slows down my program due to 
call by value.
> 
> Is there a way to work with pointers and adresses like 
is possible in C? Or is there perhaps another solution for 
my problem?
> 
> All hints are really appreciated!
> 
> Many thanks,
> J.
I recommend you take a look at:
1) Specifying reference behaviour with handle classes in 
R2008a:
http://www.mathworks.com/access/helpdesk/help/techdoc/matla
b_oop/brfylwk-1.html

2)How MATLAB's copy-on-write behaviour for value objects 
works:
http://blogs.mathworks.com/loren/2006/05/10/memory-
management-for-functions-and-variables/

3)In-place calling behaviour:
http://blogs.mathworks.com/loren/2007/03/22/in-place-
operations-on-data/

Stuart