Write a Matlab function to compute the masked spatial statistics by combing existing Matlab functions.