it's possible, but, Do you have EU passport or schengen visa?.
In Madrid to claim baggage you will go though passport control, exit landside and re check your baggage, again though security and passport control to leave schengen area.
Take note that in MAD AV is arriving to T4S and MS from T1. There's bus transfer service between these terminals, but it not run so frequently, I think that about every half hour or more...
if you have EU passport, I recommend you that only checkin to MAD, in the past I had several issues with baggage connecting from T4 to T1/2/3 because the baggage system in T4-T4S are not connected to the T1-2-3 and handling company must do manually.
Also it's more convenient, and faster, do the transfer with your baggage yourself landside, then, you must go with automatic train from T4S to T4, go through security there and take the transfer bus landside, it runs every 5minutes. Once in the T1 through security and passport control again.