Switching and Learning in Feedback Systems