Matlab script fixes