modefy the matlab code