Adding the matlab code