I just came back from the most wonderful vacation in Madrid, I went there all by myself, I was a bit scared about safety issues as my hotel (which by the way was fantastic) is very near some not quite "safe" zone. I didn't have any bad experience at all, I used to take walks at night and everything was ok, I felt quite comfortable all the time, I even went to Puerta del Sol on a Saturday night, it was packed but I didn't feel unsafe.
The only incident I had was with a taxi driver who charged me 2500 pesetas for a real short drive, it seems as if they have some kind of gadget to make the taximeter go faster, anyway it wasn't that much and when you are a tourist sometimes you expect to be paying more than the locals.
Madrid is a beautiful place to go and visit, be prepared to walk and walk and walk some more!! my feet are still swollen and blistered but it was worth it!!!
Enjoy everything!!!