Self-compensating pulsed magnetic-field gradients for short recovery times