void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{ double *y;
double *x;
unsigned int m, n;
/* Check for proper number of arguments. */
if (nrhs !=1) {
mexErrMsgTxt("Only one input argument allowed."); }
else if (nlhs !=1) {
mexErrMsgTxt("Only one output argument allowed."); }
/* The input x must be a scalar, get the size of x. */
m = mxGetM(prhs[0]); /* rows */
n = mxGetN(prhs[0]); /* columns */
if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0])
|| mxIsSparse(prhs[0]) || !mxIsDouble(prhs[0])
|| !(m ==1 && n ==1))
{
mexErrMsgTxt("Input x must be a scalar.");
}
/* Create a matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL);
/* Assign pointers to each input and output. */
y = mxGetPr(plhs[0]);
x = mxGetPr(prhs[0]);
/* Call the timestwo subroutine. */
timestwo(y, x);
}
Je l'ai enregistré sous "timestwo.c".
Sous matlab, j'ai fait:
<<mex -v -g timestwo.c
ça me crée la .dll
et quand je l'exécute << timestwo(0,1) par exemple il m'affiche cette erreur ??? Only one input argument allowed.