When is your trip? Madrid can be very, very hot in the summer. Barcelona can be hot but not to the same degree. That's something to take into consideration. I wrote the rest of this post before thinking about the weather factor.
I'll disagree with Dave, and not just because Madrid is quicker to get to by train and I don't like flying in the middle of a vacation. I love Barcelona far more than Madrid, but a very short trip to Barcelona is, in my opinion, pretty frustrating. There's just so much to see there, and a lot of the most popular sights really require that you pre-purchase timed entry tickets, because otherwise the lines are horrible. This makes it difficult to put together a super-efficient trip. Now, if you want to try it, I'd suggest that your sightseeing include the Barri Gotic (tourist office does a good walking tour, but there are other options if you can't make the timing work) and the fabulous Sant Pau modernista site. The latter is one of the few in-town modernista sites you can usually walk up to, buy a ticket and go right inside. If you just have one morning in the city, use it to snag a first-time-slot ticket to La Sagrada Familia.
If you aren't big museum fans, Madrid is a lot more manageable on a short visit. Rick has a good walking tour of the central district in his book. The San Miguel Market is a great stop in that area for tapas; I think it opens at 10 AM every day (you can check online). It's not a cheap place to grab food, but it's easy because you can look and point, and it gets you around the fact that Spaniards don't eat lunch until something like 2 PM.
However, my preference on such a short visit would be to head straight from Madrid to Toledo and stay there. The medieval upper town is huge and very atmospheric. In addition to the cathedral (where there can be lines) there are many small historic sites (see Rick's book), some of which are in the mudejar style, which you will not have encountered in France or the Basque Country. If you go to Toledo, pre-purchase your return train ticket to Madrid if you're traveling back in the evening. Rick warns that the last train sometimes sells out. In any case, you may find that the round-trip ticket costs no more than a one-way ticket.
Do not try to spend your last night in Toledo and fly out of Madrid the next day unless you have an unusually late flight departure. You can weigh what you want to do in Toledo against what you want to do in Madrid and decide how to divide your time and when to go back to Madrid.
The fare on an AVE train to either Madrid or Barcelona will be very costly if purchased at the last minute. You can save a lot if you buy early, but the cheap tickets will be non-refundable and non-changeable. You don't have to worry about the Toledo ticket, because the price there is always the same (buy the roundtrip!). However, Atocha Station in Madrid is quite the zoo, so you'll need to allow time to find the right type of vending machine (or the right ticket counter) and figure out where the platform is.