MATLAB MEX code