Skip to Main Content Skip to Search
Product Documentation

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:

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.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS