Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Modifying MEX arguments in place?
Date: Thu, 14 Feb 2008 05:45:03 +0000 (UTC)
Organization: University of California San Diego
Lines: 21
Message-ID: <fp0kgv$5ai$1@fred.mathworks.com>
References: <fp0fqv$3gd$1@fred.mathworks.com> <fp0gke$gqq$1@canopus.cc.umanitoba.ca>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1202967903 5458 172.30.248.38 (14 Feb 2008 05:45:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 14 Feb 2008 05:45:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 163259
Xref: news.mathworks.com comp.soft-sys.matlab:451309



roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fp0gke$gqq$1@canopus.cc.umanitoba.ca>...
> I know little about MEX, but generally speaking, the memory
> that you are handed for any Matlab variable might be shared
> with other Matlab variables due to the "lazy copy" behaviour.
> The columns you see might be linked to columns of other
variables.
> When you change the memory in-place, you would have
changed those
> other variables too.

I am not sure I follow: I can certainly access the
individual elements of the array that I want to modify by
read-access (and I see the right data). Why can't I write
into the same memory locations? I understand that I might be
modifying a copy of the input argument, but that does not
seem to be the case. Actually, when I look at the matrix
after I've modified the input argument and returned from the
mex file, the matrix contains correctly modified data. 
Unfortunately something else seems to have been affected,
and the Matlab interpreter stops working correctly.