finish ex2.m