formatmatrix function

Transform a matrix in 3 columns