Taking classes in an area of your interest is a great way to make friends and improve language skills in a new city. Madrid offers some courses for adults, from dance classes and photography to cooking classes.
The city government, or your local council (the town hall in Madrid) will offer courses in Spanish for immigrants (often for free), as well as in any other kind of field.
Centros Culturales Municipales are also a great resource where to find activities within your neighbourhood. They are active and public centres who provide all kind of trainings and education.
You can check the complete list of Centros Culturales Municipales and choose the one that is closer to you to find out more about the activities they organize.
A complete list of more than 235 institutions, organizations, schools, etc. that offer a big range of courses for adults can be found in Educaweb.com