fix some bugs on matlab functions