In a quadrupole mass filter, ions are directed into the space between the rods. A combination of direct current (DC) and radio frequency (RF) voltages is applied to the rods. The resulting electric field causes ions to oscillate. Only ions with a specific m/z ratio have stable trajectories and can pass through the quadrupole to the detector, while others are deflected and lost. By varying the voltages, the quadrupole can scan across a range of m/z values, allowing for the mass analysis of ions.