Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

argument of type "double" is incompatible with parameter of type "mxArray **"

187 views
Skip to first unread message

Rafael Valenzuela

unread,
May 4, 2010, 7:45:07 AM5/4/10
to
Hi :
I'm trying to call imread with mexCallMATLAB but I always get the same error that can be ? .
error: argument of type "double" is incompatible with parameter of type "mxArray **"
The code is this
<code>
double imag;
mxArray *str = mxCreateString("letras.tif");
mexCallMATLAB(1, &str, 1,imag, "imread");
printf("%f \n",imag);
</code>

Steven Lord

unread,
May 4, 2010, 9:29:52 AM5/4/10
to

"Rafael Valenzuela" <rav...@gmail.com> wrote in message
news:hrp1c3$lif$1...@fred.mathworks.com...

> Hi :
> I'm trying to call imread with mexCallMATLAB but I always get the same
> error that can be ? .
> error: argument of type "double" is incompatible with parameter of type
> "mxArray **"

That's correct. What's the signature that mexCallMATLAB expects?

http://www.mathworks.com/access/helpdesk/help/techdoc/apiref/mexcallmatlab.html

Your fourth input argument is not of the correct type. Look at the
mexcallmatlab.c example file (the first file listed in the Examples section
on that page) for an example of how to call mexCallMATLAB with inputs of the
correct type.

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


Rafael Valenzuela

unread,
May 4, 2010, 3:35:19 PM5/4/10
to
Thanks Seteven:

I've solved, I used a mxArray but this makes me take another question as you can move from a mxArray to double

"Steven Lord" <sl...@mathworks.com> wrote in message <hrp7gd$am4$1...@fred.mathworks.com>...

Steven Lord

unread,
May 5, 2010, 2:46:33 PM5/5/10
to

"Rafael Valenzuela" <rav...@gmail.com> wrote in message
news:hrpstn$9hh$1...@fred.mathworks.com...

> Thanks Seteven:
>
> I've solved, I used a mxArray but this makes me take another question as
> you can move from a mxArray to double

Look at mxGetPr and/or mxGetData.

Rafael Valenzuela

unread,
May 5, 2010, 3:28:06 PM5/5/10
to
"Steven Lord" <sl...@mathworks.com> wrote in message <hrsee5$a0k$1...@fred.mathworks.com>...
the same problem
error using mxGetData :
error: a value of type "void *" cannot be assigned to an entity of type "double"
error using mxGetPr :
error: a value of type "double *" cannot be assigned to an entity of type "double"
this is a code

James Tursa

unread,
May 5, 2010, 5:23:04 PM5/5/10
to
"Rafael Valenzuela" <rav...@gmail.com> wrote in message <hrsgs5$l33$1...@fred.mathworks.com>...

You need to post your code, not just the error messages.

James Tursa

Rafael Valenzuela

unread,
May 6, 2010, 4:42:12 AM5/6/10
to
"James Tursa" <aclassyguy_wi...@hotmail.com> wrote in message <hrsnjo$g43$1...@fred.mathworks.com>...

I so sorry , i forget the code sorry again, this is all the code
URL: http://pastebin.com/sWKhXP8D
Thx

Rafael Valenzuela

unread,
May 9, 2010, 1:51:04 PM5/9/10
to
Hi again :
the same problem , all I want to do is to run the matlab function
this is a C code http://pastebin.com/spaa98WZ .
the only problem is to move from * mxArray to double and double a * mxArray.
The problem is this http://pastebin.com/t7Gchf4M


"Rafael Valenzuela" <rav...@gmail.com> wrote in message <hrtvd4$s8v$1...@fred.mathworks.com>...

James Tursa

unread,
May 11, 2010, 10:00:22 AM5/11/10
to
"Rafael Valenzuela" <rav...@gmail.com> wrote in message <hs6sm8$4ck$1...@fred.mathworks.com>...

> Hi again :
> the same problem , all I want to do is to run the matlab function
> this is a C code http://pastebin.com/spaa98WZ .
> the only problem is to move from * mxArray to double and double a * mxArray.
> The problem is this http://pastebin.com/t7Gchf4M

e.g., this works (fres.c):

#include "mex.h"
void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]){
mxArray *theArray[9];
mxArray *imagen_out[1];
if(!mxIsDouble(prhs[0])||!mxIsDouble(prhs[1])||!mxIsDouble(prhs[2])||!mxIsDouble(prhs[3])||!mxIsDouble(prhs[4])||!mxIsDouble(prhs[5])||!mxIsDouble(prhs [6])||!mxIsDouble(prhs[7])||!mxIsDouble(prhs[8])){
mexErrMsgTxt("Must be called with a valid handle");
}
if( mexCallMATLAB(1, imagen_out, 9, prhs, "fresnel") ) {
mexErrMsgTxt("fresnell function didn't work");
}
// imagen_out[0] has the result, use it here
mxDestroyArray(imagen_out[0]); // destroy it when done with it
}

e.g., calling sequence:

>> fres(1,2,3,4,5,6,7,8,9)
Inside fresnel
45

e.g., the fresnel.m file:

function out = fresnel(a1,a2,a3,a4,a5,a6,a7,a8,a9)
out = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9;
disp('Inside fresnel');
disp(out);
end


James Tursa

Rafael Valenzuela

unread,
May 13, 2010, 4:09:05 AM5/13/10
to
"James Tursa" <aclassyguy_wi...@hotmail.com> wrote in message <hsbntm$i6e$1...@fred.mathworks.com>...

Hi James Tursa
My fresnel function doesn't make exactly that, the problem is the cast type between mxArray and double.

this is a head of my function :fresnel(imagen,l,z,tax,tay,fx,fy,n,m) and it returns a Imagen , all parameters it's double, the question is .
it's possible to convert a mxArray to double?.
Moreover i need to use a C function no Matlab function

0 new messages