Okay! I agree with teachertraveler: always use your common sense, the sense less commonly used. smile

I'm from Madrid, but I'll try to be objective because security it's an important matter to consider.
If you're visiting the city alone, i would suggest to get a tour, as some user said above. It's better to have a general overview of the city first, locate the barrios and main places, so you can choose where to go on your own in your spare time. And of course being able to meet people in your same situation.

City center is usually crowded at night, so you never feel alone and, if you avoid certain streets (not the main ones), there should be no problem at all.
I'm sure the frontdesk people of the hotel where you may be staying, would be more than willing to help with indications and advise.

Of course, local people are nice and will also help you. smile