Convert matrix to numbers