updated MATLAB code