Converts a matrix to an object.