If you want to keep a process running (or, rather, restart it if it exits) use
launchd. There's a recipe for keeping TextEdit alive here, and Lingon is available as a GUI to set it up.
This isn't perfect for your particular problem, though -
launchd will restart your process whenever it exits, regardless of whether it was successful or not. This could be a big pain if your program were to overwrite the perfectly good output from the previous run. To get round this, you could wrap your program in a script (a shell script would do) that would run the program, then, if it was successful, remove the
launchd job before exiting. Something like:
#$? is the exit value of your program - convention is 0 for success, non-zero otherwise
if [ $? = 0 ]
launchd unload keep.my.matlab.running
If Matlab produces output as fideli suggests, you could use a folder action on the folder that Matlab would put its error report into. Simply write an Applescript or Automator workflow that takes the files that have been added, checks if they are a Matlab error and, if so, sends you an e-mail. One of the built-in ones is called "new item alert" and is probably a good starting point for some genetic modification.