The engines will be a direct drop - as they are the same generation of engine. The Matrix is just a "wagon variant" of the Corolla, they share the same drivetrain and chassis. Only difference between the 2003 and 2004 model years were mainly in the transaxle - 5-speed manual had different syncros, everything else is the same.
Should not have any issues with the ECM - as long as you stay in this narrow model year range (2003-2004) - should not have any issues. If you bump it up to the 2005+ 1ZZ-FE or drop to the 8.5th gen 1ZZ-FE (2000-2002) - then you are looking at some headaches.
Depending on what happened to the blown engine - you could just replace what was damaged, ie. if the valvetrain is screwed up, but the block is fine - just replace the top end - if the crank bearings were trashed, just replace the short block, reuse everything else.
But sometimes - it is just faster/cheaper to just drop in a good condition engine from a donor car.