Calculating the Matrix table values