finished p2 matlab