A couple of observations here:
1. G0 vs. G1. G0 is used for rapid positioning of the cutting tool (Router, Plasma, Laser, etc.) and G1 is usually moved for a programmed cutting move at set feed rate.
2. G-Code file. This automation is the whole basis of a G-code file. You would use whatever CAM software you have available (I'm not familiar with Matlab, but it sounds like it could work) to generate the output into a g-code file (.NC, .TAP, etc.) and then use Mach3 to load the file and run it.
Bear in mind a complete g-code file will have additional commands and should be run through a Post-processor to format it correctly for Mach3 as well as ensure the proper sequence of commands are added/followed. Other methods _could_ be used to automate the output from your programs, but this is what Mach3/4 are designed for - proceessing G-code files!
Stephen "Highspeed" Kruse