Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Passing function arguments to Matlab via Matlab Engine
Replies: 1   Last Post: Jan 29, 2013 1:26 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
James Tursa

Posts: 2,096
Registered: 8/5/09
Re: Passing function arguments to Matlab via Matlab Engine
Posted: Jan 29, 2013 1:26 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.