Stuart’s MATLAB Videos

Watch and Learn

Adding a try/catch With Email Notification

One module of a large MATLAB project I maintain failed last night and caused the whole application to error-out. This is disappointing because it takes several hours to run. It was because of a typo I had entered into a string in a spreadsheet; something I might do again.

So I want add a try/catch statement around this piece of code to ensure the system is robust to the issue in the future. Also, because I want to address the root cause of the error (string typos) and the fact that the code runs during the night, I want to send myself an email notification when it fails.

Features covered in this code-along style video include:

  • try/catch, str2func
  • sendmail

Play the video in full screen mode for a better viewing experience. 

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.