Madrid can be surprisingly COLD. I was there once at the start of September and it snowed.
Madrid is traditionally said to experience "nueve meses de invierno y tres meses de infierno" - nine months of winter and three months of Hell.
So take warm clothes.