Martin Demichelis will join La Liga side Espanyol on a free transfer following his departure from Manchester City.