What makes my Ford F-150 run rough?

I have a 2009 F-150. It runs like a dream most of the time. But, sometimes, when I'm slowing down to come to a stop, it will run very rough and sound like it is rattling underneath. This only lasts for about a minute or two, then after I come to a complete stop and before I turn off the key, it stops running rough and runs normal again. What could be causing this?

If there was a problem with the battery or alternator, the battery light would light up yellow or red.
This symptom points to carbon build up the butterfly valve in the intake where the air intake assembly connects to the manifold. Look up how to clean it as not all vehicles were created the same.

Check your alternator output, at the battery. Should read around 13.6 volts with lights and heater on, running. Also check your battery for a load test at a battery shop, could have a couple of weak cells. Not getting enough voltage or amps to the coil for proper output.

Thank you. I will check that out. It is a brand new battery. I will have it checked, too.