Let A be a real matrix with all distinct eigenvalues. We propose a new method for the computation of the distance w_R(A) of the matrix A from the set of real defective matrices, i.e., the set of those real matrices with at least one multiple eigenvalue with algebraic multiplicity larger than its geometric multiplicity. For 0 < ε ≤ w_R(A), this problem is closely related to the computation of the most ill-conditioned ε-pseudoeigenvalues of A, that is, points in the ε-pseudospectrum of A characterized by the highest condition number. The method we propose couples a system of differential equations on a low-rank manifold which determines the ε-pseudoeigenvalue closest to coalescence, with a fast Newton-like iteration aiming to determine the minimal value ε such that an ε- pseudoeigenvalue becomes defective. The method has a local behavior; this means that, in general, we find upper bounds for w_R(A). However, these bounds usually provide good approximations, in those (simple) cases where we can check this. The methodology can be extended to a structured matrix, where it is required that the distance be computed within some manifold defining the structure of the matrix. In this paper we extensively examine the case of real matrices. As far as we know, there do not exist methods in the literature able to compute such distance