Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Error Handling for MATLAB Code

You can add MATLAB® code to a report, by using the Evaluate MATLAB Expression component (also called the Eval component). See Add MATLAB Code for details.

The Evaluate MATLAB Expression component dialog box includes an Evaluate this expression if there is an error check box. The dialog box includes default error handling code that you can use, or you can create your own error handling code.

If you do not change the default error handling code, then when you generate the report, and there is an error in the MATLAB code that you added:

  • If you clear Evaluate this expression if there is an error check box, then the complete report is generated, without displaying an error message at the MATLAB command line.

  • If you select Evaluate this expression if there is an error check box, then the complete report is generated and an error message appears at the MATLAB command line.

To stop report generation when an error occurs in the MATLAB code that you added, change the second and third lines of the following default error handling code, as described below:

warningMessageLevel = 2;
displayWarningMessage = true;
failGenerationWithException = false;
failGenerationWithoutException = false;

To stop report generation and display an exception, change the default code to:

displayWarningMessage = false;
failGenerationWithException = true;

To stop report generation without displaying an exception, change the default code to:

displayWarningMessage = false;
failGenerationWithoutException = true;

If you want to completely replace the default error handling code, use the evalException.message variable in your code to return information for the exception.

Was this topic helpful?