assignment 2 with few more validations

validation done to check if the variable passed is matrix or not..