calculates the  percentage values in the matrix