mat_to_rowcolval function

Convert a matrix to a data frame with rows, columns, and values.