finish ex2_reg.m