The level of challenge in stroke rehabilitation has to be carefully chosen to keep the patient engaged and motivated while not frustrating them. This paper presents a simulation where this level of challenge is automatically optimized using iterative learning control. An iterative learning controller provides a simulated stroke patient with a target task that the patient then learns to execute. Based on the error between the target task and the execution, the controller adjusts the difficulty of the target task for the next trial. The patient is simulated by a nonlinear autoregressive network with exogenous inputs to mimic their sensorimotor system and a second-order model to approximate their elbow joint dynamics. The results of the simulations show that the rehabilitation approach proposed in this paper results in more difficult tasks and a smoother difficulty progression as compared to a rehabilitation approach where the difficulty of the target task is updated according to a threshold.