Problem with MexFunction and MexGetPr
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael Negosanti
am 14 Jul. 2019
Bearbeitet: James Tursa
am 15 Jul. 2019
Good morning,
I can't solve the problem of assignment from incompatible pointer type for the x and y pointer. The error that develops in Matlab, could be caused by the wrong use of the mxGetPr function for the x and y matrix pointers, but I don't know how to proceed.
Someone could give me directions.
thank you.
void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray*prhs[] )
{
double **x;
double *z;
double *p;
double **y;
int i = 2;
int j = 5;
plhs[0]= mxCreateDoubleMatrix((mwSize)i, (mwSize)j, mxREAL);
x = mxGetPr(prhs[0]);
z = mxGetPr(prhs[1]);
p =mxGetPr(prhs[2]);
y = mxGetPr(plhs[0]);
functionsum(y,x,z,p);
return;
}
0 Kommentare
Akzeptierte Antwort
James Tursa
am 15 Jul. 2019
Bearbeitet: James Tursa
am 15 Jul. 2019
Impossible to answer without seeing the code for the functionsum( ) function. Maybe you could post that? Maybe all you need to do is this (but this is just a guess w/o seeing your code):
double *x;
double *z;
double *p;
double *y;
What version of MATLAB are you using?
Btw, you don't need to explicitly cast the i and j arguments since C has automatic type promotion. This would suffice:
plhs[0]= mxCreateDoubleMatrix( i, j, mxREAL);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!