updated matlab code