We demonstrate an empirical magnetic field gradient waveform optimization technique which compensates for eddy current distortions and nonideal gradient amplifier performance. The desired gradient response is used as a trial function, and a pickup coil in the magnet bore detects the actual pulsed gradient. The temporal behavior of the gradient is digitized and recorded with the existing NMR spectrometer hardware and is used for the calculation of a new trial function table. The method and some typical results as well as some practical considerations are described.