updated matlab functions, have not tested