Complete first part of Ex2

Complete the ex2.m part. Still missing the regularization.