Path: news.mathworks.com!not-for-mail
From: "Ashish Uthama" <first.last@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mex file wrapper for dll needing function handle
Date: Tue, 03 Mar 2009 16:49:07 -0500
Organization: TMW
Lines: 36
Message-ID: <op.up8j75y1a5ziv5@uthamaa.dhcp.mathworks.com>
References: <goimue$6j6$1@fred.mathworks.com>
 <op.up8he7c6a5ziv5@uthamaa.dhcp.mathworks.com>
 <gok6s7$6oc$1@fred.mathworks.com>
NNTP-Posting-Host: uthamaa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1236116947 10754 172.31.57.126 (3 Mar 2009 21:49:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Mar 2009 21:49:07 +0000 (UTC)
User-Agent: Opera Mail/9.63 (Win32)
Xref: news.mathworks.com comp.soft-sys.matlab:522259


On Tue, 03 Mar 2009 16:19:03 -0500, James Tursa  
<aclassyguywithaknotac@hotmail.com> wrote:

> "Ashish Uthama" <first.last@mathworks.com> wrote in message  
> <op.up8he7c6a5ziv5@uthamaa.dhcp.mathworks.com>...
>>
>> mxCreateScalar will help you convert a double to a mxArray.
>>
>> //air code!
>> mxArray* prhs[3];
>> mwSize dims[2]={ 1 1};
>> prhs[0]=mxCreateNumericArray(2,&dims, mxDOUBLE_CLASS,mxREAL);
>> mexGetPr(prhs[0])=x;
>> //..so on for y and z
>>
>
> Couple of typos. Since dims is an array, it will act as a double * when  
> passed, so you don't need the &dims in the call, just dims. And you are  
> missing a comma in the dims initialization. Also, mxGetPr returns a  
> pointer result that is not an lvalue. You need to dereference it for the  
> assignment. e.g.
>
>  mxArray* prhs[3];
>  mwSize dims[2]={ 1, 1};
>  prhs[0]=mxCreateNumericArray(2,dims, mxDOUBLE_CLASS,mxREAL);
>  *(mexGetPr(prhs[0])) = x;
>
> Or, as you almost pointed out, you can use mxCreateDoubleScalar for this:
>
> prhs[0] = mxCreateDoubleScalar(x);
>
> James Tursa


not typos..but plain errors :)
thanks for the corrections.