First I'll characterize those finite metric spaces with well-defined metric dimension in terms of the purity of a related [simplicial complex][1] and then briefly talk about how [matroids][2] fit into the picture.

# Simplicial Complex Background
We will need some terminology for (abstract) [simplicial complexes][1]. A _simplicial complex_ on a set $S$ is a collection of subsets $\Delta$ of $S$ that is closed under taking subsets, that is, if $T \in \Delta$ and $T' \subseteq T$, then $T' \in \Delta$. The elements of $\Delta$ are called its _faces_ and the inclusion-maximal faces are the _facets_ of $\Delta$. The _rank_ of a face $F$ is given by $r(F)=\#F$ and the _rank_ of $\Delta$, denoted $r(\Delta)$, is the largest rank of a face in $\Delta$.

Note that for a general simplicial complex, the cardinality of two facets need not be equal. (Example: $([3], \{\emptyset, 1, 2, 3, 23\})$.)  However, if all facets do have the same cardinality the simplicial complex is called _pure_.

# A (nearly trivial) characterization

Let $(M,d)$ be a _finite_ metric space and let $\mathcal{G}$ be the collection of all generating sets for $(M,d)$. Define the set

$$\Delta = \Delta(M,d) := \{M \setminus G~|~G \in \mathcal{G}\}.$$

Note that if $G' \supseteq G$ and $G \in \mathcal{G}$ then $G' \in \mathcal{G}$. This impies that the set $\Delta$ is an abstract simplicial complex on $M$. The facets of $\Delta$ correspond to cardinality-minimal generating sets of $(M,d)$ by set complementation. So the metric dimension of the finite metric space $(M,d)$ is well-defined if and only if the complex $\Delta(M,d)$ is pure. In this case, $\dim(M,d) = \#M - r(\Delta)$.

# Matroids
Now let me try to tie this into the matroid discussion in Example 1 of [this answer][3] to the [previous question][4]. In that example we have $M = \{0,1,2,3\}$ and $d$ given by

$$d(x,y) = \begin{cases} 2 \text{ if } x,y \neq 0 \\ 2 + \frac{1}{y} \text{ if } x = 0. \end{cases}$$

One computes that $\mathcal{G}$ is all subsets of $\{0,1,2,3\}$ except for the empty set and the singletons $\{i\}$ where $i \in [3]$. So $\Delta(M,d)$ is the simplicial complex 

<strike>consisting of all subsets of {0,1,2,3} that do not contain 0</strike>

whose faces are arranged by containment in the following poset. So $\Delta(M,d)$ is not pure (it has three facets of rank two and a facet of rank three) and so the metric dimension for $\Delta(M,d)$ is not well-defined. 


[![The face poset of $Delta(M,d)$][5]][5]


For an arbitrary finite metric space $(M,d)$, the complex $\Delta(M,d)$ is a matroid (that is, its facets satisfy the basis exchange axiom for matroids) if and only if the "matroid dual" complex

$$\Delta^*(M,d) := \{H \subseteq G | G \text{ is inclusion-minimal in } \mathcal{G}\}$$

is a matroid. In this case the metric dimension of $(M,d)$ is just the rank of $\Delta^*(M,d)$.


  [1]: https://en.wikipedia.org/wiki/Abstract_simplicial_complex
  [2]: https://en.wikipedia.org/wiki/Matroid
  [3]: https://mathoverflow.net/questions/275493/when-does-a-metric-space-have-infinite-metric-dimension-definition-of-metric/275771#275771
  [4]: https://mathoverflow.net/questions/275493/when-does-a-metric-space-have-infinite-metric-dimension-definition-of-metric
  [5]: https://i.sstatic.net/fD3Zp.png
  [6]: https://en.wikipedia.org/wiki/Uniform_matroid