I've walked alone at all hours of the night in various areas of Madrid. I'm a tall fair American female - so I do stick out. I'm originally from NYC so I have eyes and ears in the back of my head. I wouldn't recommend doing it if you've had a lot to drink or if you will be nervous and project that image. I find people tend to leave you alone if you walk agressively and with purpose and they think you know where you are going (even if you are lost)

Cabs are relatively cheap and it can't hurt
_________________________
great music: www.benjaminwagner.com
have a listen!