add previous Matlab code