How can a nonlinear field gradient be generated in NMR?
Regular off-the-shelve pulsed field gradient (PFG) systems only give linear gradients, obviously. However you can produce higher-order gradients with your shim coils, normally to compensate similar opposing unwanted gradients in the field of the main magnet.
So, by manipulating the shim set, you can create any odd gradient field that you can sufficiently approximate with the terms that your shim system supplies (usually up to 5th order in $z$). To find out what exactly the terms are (coordinates and absolute amplitudes), you can image them using the regular PFG system.
There are two hitches: You cannot switch the shim system quite so fast as the dedicated PFG set, and the &quot;room temperature&quot; shim system isn't nearly as powerful as a PFG, so you are limited in terms of gradient strength. (The &quot;cryoshims&quot; are stronger, but you cannot switch them, as they are superconducting.)
So, if you're OK with a static gradient of low amplitude, you can go straight ahead. If you need it to be pulsed, give it a try. It's been done before, switching shim currents during a pulse sequence. Very good chance to really get to know the insides of your spectrometer system.

If you're secretly an engineer also, check my other answer. ;)