You have a few options. But for such a short stay like 3-weeks it'll be tough to find much economical. In your situation I'd recommend visiting the website
http://www.VenAMiCasa.com for Madrid, Seville, Barcelona, and Granada - to name a few.
There, they rent rooms in family flats. This is not necessarily a "home stay" with all the family interactions like cooking, taking out the garbage, helping with house cleaning chores and the like. I think it's simply a room rental. Of course, all situations are different. They charge by the night but some of the prices were really cheap, about 15-25 Euros per night.
And while this doesn't really apply to you since you only plan to spend 3-weeks in Madrid, but there was a report on Madrid Directo on TV just this afternoon about the flood of university students returning/going to Madrid for studies and looking for lodging. The report focused on shared living arrangements with 3 or 8 other roommates, all dividing expenses. Most were renting houses/chalets outside of downtown Madrid and were paying 400-500 Euros each per month. This sounds like a lot to me but you should've seen some of the houses these
kids were renting. They were huge! Anyway, they showed all the paper postings on bus stop shelters on the campus areas - they were covered with them!
Best of luck to you! Saludos, MadridMan
_________________________
Visit BarcelonaMan.com for Barcelona information, Transportation, Lodging, & much MUCH more!
Curious about what could POSSIBLY be inside the brain of MadridMan? Visit
MadridMan's Madrid Blog