We flew INTO Madrid on Delta a few weeks ago. Even though our hotel was just behind Atocha station and train goes right to it, fortunately I knew ahead of time that Delta comes in to the "old" T1/T2/T3" complex and the train does not stop there. So taking the train would have involved a shuttle over to T4. Since Delta is about the only international airline coming into T3, customs, immigration, luggage was a breeze. We took a taxi to hotel. Total time gate to hotel was just over an hour, with the taxi being about 25 minutes (early on a Friday 2 weeks ago).
The flat rate was 33eu. Very glad we did the taxi.
Be sure you know what terminal, especially if on Delta.