Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Passing function arguments to Matlab via Matlab Engine
Posted:
Jan 29, 2013 1:26 PM
|
|
"mayur" wrote in message <ke88sc$q9$1@newscl01ah.mathworks.com>... > > I did the following which i am not sure if its correct .. please help.. > > A = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); // created a numeric matrix of size 1 and of type double > memcpy(&A,&Amp,sizeof(double)); // copied over the memory from the input argument over to the mxArray..
The above line is an error. What you have done is copy the value of Amp into the first 8 bytes of the mxArray structure of A. What you *want* to do is copy the value into the *data* area of A instead. E.g.,
*mxGetPr(A) = Amp;
or using memcpy:
memcpy(mxGetPr(A),&Amp,sizeof(double));
James Tursa
|
|
|
|