Function to copy a matrix with dimension n to a matrix with dimension n+1