About a month ago my 2003 Hyundai Elantra's check engine light came on. Afterward I noticed that a couple minutes into my drive it would slow and although I pressed on the accelerator it seemed to barely react. Over the weeks the problem has continued to get worse. Now when I start my car I wait for about 3 minutes for it to do this same behavior. The RPMs drop down and it acts as though it may stall and it runs very rough. I leave it in park the whole time. After about 30 seconds it seems to correct itself and suddenly the RPMs rise as though I'm flooring it for a couple seconds before dropping. After this my car runs fine for my 45 minute commute both in-town and on highway driving. I haven't been able to find anything else on forums that sound like it.
I would test the IAC (idle air control) system. There are two valves, a mechanical one that operates in open and closed loop mode (open : engine not warmed up, closed : engine warmed up), and a electronic controlled valve that only operates in closed loop. If the issue only happens once warmed up and driving around the IAC is most likely your problem, although i would test it.
Faulty throttle position sensors usually cause loss of power followed by surges. Faulty IAC usually cause surges followed by loss of power. Know that difference can help diagnose.
The reason for this is when the IAC valve fails the engine vacuum forces the valve open hence the engine surges, then the ECU trys to compensate to bring the engine back down. When a MAP/MAF or throttle position sensor fail, the ECU just gets erroneous data that your foot is no longer on the pedal or there isn't enough air so less fuel goes into the combustion chamber... so you lose power. Then once the sensor is past the blind spot the ECU realizes the error and surges do to overcompensation.
So does the engine lose power then surge or vice versa? If both you might have a handful of issues that need diagnosing.