method to filter out rows of matrix data