calculates the local average of a matrix. excercise-3. yr-2.