There are two routes, and they're not equal.
Best route: find the original. If you can track down the tin, the old decorating quote, or even a faded label in the loft, you've sorted it. The same colour from the same brand will always beat a scanned approximation. Even if the original tin is dried up, the name and brand are gold. Most of the supported brands — Farrow & Ball, Little Greene, Dulux, Crown, Benjamin Moore — keep their ranges going for years, so a colour from a decade ago is usually still available.
Second route: get it scanned. Cut a clean, flat chip of the existing paint — ideally peel a small flake from an inconspicuous spot, or paint a patch onto card and let it cure fully. Take it to a decorator's merchant with a spectrophotometer (Brewers and most trade counters have one). The machine reads the colour and mixes a match in your chosen base.
Here's the honest bit: a scanned match is rarely spot-on. The machine reads what's on the wall *now* — which has yellowed, faded, or dirtied over the years. So you may end up matching the aged colour, not the original. And different brands use different bases and finishes, so a Dulux scan put into a Crown emulsion can read subtly off. Expect to be within a whisker, not identical.
The practical move: if you're matching one wall to three existing ones, don't bother chasing perfection — repaint the whole room in a fresh colour. You'll never get an invisible patch repair on an aged finish, and the difference in sheen alone will give you away under raking light.
If you genuinely need a patch, paint a test patch first, let it dry a full 24 hours, and view it in daylight before committing. Wet paint always looks wrong. And keep a labelled tin of leftover paint from now on — future you will be grateful.