matlab code and python preliminary