Matlab Euler mesh optimization code