moved matlab code here