adapted to matlab