Improved matlab train