adding functionality for main program to run a matlab file and wait for it to finish