Excitation of accelerating wakefields in inhomogeneous plasmas