This paper considers the problem of flying a UAV along a given trajectory at speeds close to the speed of sound and above. A novel pitch channel control system is presented using the example of a trajectory with rapid and large changes in flight height. The control system uses a proportional–integral–differential (PID) controller, whose gains were first determined using the Ziegler-Nichols II method. The determined gains were then optimised to minimise height error using a recurrent back-propagation neural network (PIDNN), with which new controller gains were determined, which is also a novelty of this study. Simulations were carried out for flights at subsonic speeds close to the speed of sound and supersonic speeds, at low and high altitudes. The simulations showed that determining controller gains using a recurrent neural network significantly minimises height errors and increases the flexibility of the PID controller.