Is there a way to just automatically exit matlab if an error occurs? Or something like resume on error?
Note that when you use -r, you can include multiple statements to be
executed by putting them in double quotes.
The command [matlab -r "try, unmodifiableCodeThatMayError, catch,
handleTheError, end, exit"] should do what you want (for appropriate values
of unmodifiableCodeThatMayError and handleTheError, of course.)