what affects the strength of a magnetic field