This started about a week ago. I put the heat on and about after driving a couple of miles with the heat on it would randomly blow out cold air. Sometimes if I turned the heat off or switched it from cold back to hot it would work again. How would I go about fixing this or even knowing what the cause of the problem is? Also, this is the first time this has ever happened to me and I have owned the car for a little over 4 years now. 2001 Nissan Altima.
Does your car overheat too?
If so, you could have a faulty thermostat, an air pocket in your cooling system or maybe even a leak somewhere. My truck's heat would only work while I was driving, then stopped working altogether while the engine started to overheat. I changed the thermostat, then the heat would blow hot/cold/hot/cold, I didn't realize you had to bleed the air out of the system after changing the thermostat. I did that and now the heater and engine run great.
First check would be that the engine has sufficient coolant. (NB Do not remove the radiator cap when hot). Second check is that the engine is reaching operating temperature - does the temp gauage rise and show hot?. If these items pass inspection, then the very probable fault is with the AirCon module. When you turn the AirCon on, the module shuts off the flow of water to the heater. When you turn the AirCon off, the module opens the flow of water to the heater. A mis-behaving module would give you the heater performance you are experiencing. A system scan of the AirCon should highlight the fault.
You may have air in your radiator core but this does not go inline with putting air condition cold/hot fixing it. It is possible that the air mixture flap of the heater core is somehow loose perhaps? or if it is automatic climate control, the flap motors or some valves may be faulty.
Automatic air conditioned cars have some valves/flaps which regulate the air conditioning system.
For example in some jaguar cars the DCCV (dual climate control valve) valve may get broken and the solenoids stick and this will cause giving out hair all of a sudden. While your situation the problem is cold air, it may be how this system gets stuck in your car. When you put all the way to hot-cold-hot again, the solenoid can get loose and start working again for a while.
Also cars use flaps to regulate air mix from heater core (it is in your dash somewhere) to achieve correct temperature. The temp. sensor in the vent checks the temperature and tries to set the amount of air passing through the heater core. Most automated flaps use motors with variable resistance devices so the computer can adjust how much the flap is open based on the resistance value. These resistors wear out in time and may give wrong signals if the resistance track is damaged. Again, moving it back-and-forward all the way by setting hot-cold-hot can make it work for a while.
Your car computer may have information about this. Eg. in VW cars the climatronic system can record the flap position values and figure out if there are strange values and record this. But this wont cause an engine light to be on.
It is unfortunately difficult to guess what may be the actual problem with so little information.