Barcelona and Madrid are very large and beautiful cities, each well worth at least 4 days.
If I were in your shoes and wanted to have fun I would make my first visit to Madrid. Make that my hub. If I had 6 days, then I would spend 4 enjoying all Madrid has to offer, the museums, the nightlife and take two one-day each side trips to Toledo and Segovia.
The lovely city of Segovia, where you will find a Roman Aqueduct, the best cochinillo (roast pig), and one of the most charming castles in Spain. That is a one day side trip.
Then I would recommend a visit to Toledo, the city is a work of art in and of itself. It is a jewel.
The train or bus ride to Toledo is about an hour by train. Segovia is about 2 hours.
You can read all about the Madrid nightlife; Toledo and Segovia by doing a quick search.
The world is a book, and those who do not travel read only a page.
--St. Augustine (354-430)