A method is presented to optimize selection for traits that can be repeatedly measured along trajectories. Covariance functions can be used to describe the variance-covariance structure of traits measured at different points. From this, eigenfunctions are derived, giving insight into the scope for changing the trajectory (e.g. a growth curve). Associated with eigenfunctions are canonical variables. Selection can be optimized by finding index weights for the canonical variables that maximize profit from the resulting genetic change. The method is illustrated with a beef cattle example, showing that selection for final weight is less optimal than optimized selection where change of initial weight gain is restricted. The methodology outlined in this paper can be a basis for selection for multidimensional trajectories to jointly optimize genetic change for weight, fat and muscle, along with correlated changes in mature weight and onset of puberty.