Modern building codes allow the analysis and design of earthquake-resistant structures with recorded and/or generated accelerograms, provided that they are compatible with the elastic design spectrum. The problem then arises to generate spectrum-compliant accelerograms with realistic non-stationary characteristics, which in turn may play an important role in the non-linear seismic response. In this paper, an iterative procedure based on the harmonic wavelet transform is proposed to match the target spectrum through deterministic corrections to a recorded accelerogram, localised both in time and frequency. Numerical examples demonstrate the performance of this approach, which can be effectively used in the design practice.