Moved matlab code