1 #include "mex.h"
2
3 void
mexFunction(int nlhs,mxArray * plhs[],int nrhs,const mxArray * prhs[])4 mexFunction (int nlhs, mxArray *plhs[],
5 int nrhs, const mxArray *prhs[])
6 {
7 char *str;
8
9 mexPrintf ("Starting file myfeval.mex\n");
10
11 mexPrintf ("I have %d inputs and %d outputs\n", nrhs, nlhs);
12
13 if (nrhs < 1 || ! mxIsChar (prhs[0]))
14 mexErrMsgTxt ("ARG1 must be a function name");
15
16 str = mxArrayToString (prhs[0]);
17
18 mexPrintf ("I'm going to call the function %s\n", str);
19
20 if (nlhs == 0)
21 nlhs = 1; // Octave's automatic 'ans' variable
22
23 /* Cast prhs just to get rid of 'const' qualifier and stop compile warning */
24 mexCallMATLAB (nlhs, plhs, nrhs-1, (mxArray**)prhs+1, str);
25
26 mxFree (str);
27 }
28