Distance functions on subsets of matrices