A magnetic system for biosensors is switchable between attraction force and repulsion force near the sensor surface. The magnetic system includes a magnetic source and a sensor. The sensor corresponds with the magnetic field in a way that the magnetic source creates inhomogeneous magnetic field lines that results in a magnetic force towards the magnetic system and which subsequently or adjacently exerts a magnetic force directed away from the magnetic system with all magnetic forces generated at the same magnetic source.