Controlled switching in Kalman filtering and iterative learning controls