An analytical solution to a matrix Riemann-Hilbert problem