Just for comparison, here is a C MEX file for the same callback:
// vanderpol.c
#include "mex.h"
#include "matrix.h"
#include "vanderpol_mod.h"
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
// Value of independent variable
const double *t = mxGetDoubles(prhs[0]);
// Get number of rows in column vector y
const int m = mxGetM(prhs[1]);
// Get pointer to dependent variables
const double *y = mxGetDoubles(prhs[1]);
// Create output buffer
plhs[0] = mxCreateDoubleMatrix(m,1,mxREAL);
double *dydt = mxGetDoubles(plhs[0]);
f_vanderpol(&m,t,y,dydt);
}
To compile this function use the command
mex -R2018a vanderpol.c vanderpol_mod.o