updated matlab script