A matrix minimization problem involving ranks