Adjusted MATLAB code to compile also with Octave's mkoctfile --mex.