completed prediction part using fminunc