Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mxCreateDoubleMatrix() function
Date: Thu, 1 Oct 2009 05:08:01 +0000 (UTC)
Organization: Boeing
Lines: 20
Message-ID: <ha1dfh$202$1@fred.mathworks.com>
References: <h9vvuk$qip$1@fred.mathworks.com> <ha07a3$bg6$1@fred.mathworks.com> <ha1735$j6n$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1254373681 2050 172.30.248.37 (1 Oct 2009 05:08:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 1 Oct 2009 05:08:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:574119


"Geoffroy " <grsabourin@gmail.com> wrote in message <ha1735$j6n$1@fred.mathworks.com>...
> Yes I have finally found this function but I don't have any result. If I call the function like that
> 
> const mwSize dims[]={3,3};
> const mwSize NbDimension = 2;
> MatlabArray = mxCreateNumericArray( NbDimension, dims, mxUINT16_CLASS, mxREAL );
> 
> I put the variable like that
> engPutVariable( m_pEngine, in_VarName.c_str(), MatlabArray ) ;
> 
> I obtain a 3x3 matrix in the matlab workspace ( only one dimension)
> 
> If I try to increase the dimension the function return 0
> 	const mwSize dims[]={3,3};
> 	const mwSize NbDimension = 4;
> 	MatlabArray = mxCreateNumericArray( NbDimension, dims, mxUINT16_CLASS, mxREAL );

That's because you are reading beyond the end of valid memory. dims still just has 2 elements the way you have written it, not 4. You need to give dims 4 elements, e.g. dims[] = {3,3,3,3}.

James Tursa