The most basic color matching involves selecting a tie to wear with a dark suit and a white dress shirt. It is difficult to go wrong with this combination and your main decision is whether to keep with subdued tones or go for a brighter look.
The same holds true for matching a fine gauge knit with a pair of dark trousers. If you are wearing a colored solid dress shirt, select a patterned tie that uses the dress shirt hue as a secondary color. Use the same logic if you are wearing a patterned pair of trousers (glen plaid, houndstooth, etc.). Select a knit or woven shirt that matches the secondary color in the trouser pattern.
Matching a patterned suit or sport coat with a dress shirt and tie is more complex. A few options are acceptable. You can select a shirt that is a lighter shade of the primary suit color and match it with a tie that emphasizes the suit's secondary tone. For example, if you are wearing a light brown sport coat with a burgundy over bar, you might select an ecru dress shirt and match it with a small-patterned tie with burgundy as the primary color. Or, you can select a shirt color that emphasizes the burgundy in the sport coat, and match it with a tie that has a light brown as the secondary hue.
As with most elements of business dressing, select color combinations that you are comfortable wearing.