avoid memory access violation in Matlab interface