matlab function used to solve quiz from week 1