A New Method for the Measurement of Inhomogeneous Magnetic Fields