Exit with non zero return code if a Matlab training example fails (rebased onto develop)



This is the same as gh-1411 but rebased onto develop.

----

We do not have any proper Matlab integration tests at the moment but daily run the training examples job against the latest server.

This PR causes all the Matlab training scripts to return a non-zero return code if an error is captured. This should cause the corresponding training example job to fail.