A fast and accurate numerical method for the solution of scalar and matrix Wiener-Hopf (WH) problems is presented. The WH problems are formulated as Riemann-Hilbert problems on the real line, and a numerical approach developed for these problems is used. It is shown that the known far-field behaviour of the solutions can be exploited to construct numerical schemes providing spectrally accurate results. A number of scalar and matrix WH problems that generalize the classical Sommerfeld problem of diffraction of plane waves by a semi-infinite plane are solved using the approach.