Potential Differences Reporting - MATLAB & Simulink (original) (raw)

Main Content

Generation of efficient C/C++ code from MATLAB® code sometimes results in behavior differences between the generated code and the MATLAB code. When you run your program, run-time error checks can detect some of these differences. By default, run-time error checks are:

To help you identify and address differences before you deploy code, the code generator reports a subset of the differences as potential differences. A potential difference is a difference that occurs at run time only under certain conditions.

Addressing Potential Differences Messages

If the code generator detects a potential difference, it displays a message for the difference on the Potential Differences tab of the report. If you use theMATLAB Coder app to generate code, you can view the message in thePotential Differences tab of the app itself. To highlight the MATLAB code that corresponds to the message, click the message.

The presence of a potential difference message does not necessarily mean that the difference will occur when you run the generated code. To determine whether the potential difference affects your application:

If your analysis or testing confirms the reported difference, consider modifying your code. Some potential differences messages provide a workaround. For additional information about some of the potential differences messages, see Potential Differences Messages. Even if you modify your code to prevent a difference from occurring at run time, the code generator might still report the potential difference.

The set of potential differences that the code generator detects is a subset of the differences that MEX functions report as errors. It is a best practice to test a MEX function over the full range of application data.

Disabling and Enabling Potential Differences Reporting for MATLAB Coder

By default, potential differences reporting is enabled for:

To disable potential differences reporting:

By default, potential differences reporting is disabled for the Generate code step and the code generation report in the MATLAB Coder app. To enable potential differences reporting, in theDebugging settings, select the Report differences from MATLAB check box.

Disabling and Enabling Potential Differences Reporting for Fixed-Point Designer

By default, potential differences reporting is enabled for code acceleration withfiaccel. To disable it, in a code acceleration configuration object, set ReportPotentialDifferences tofalse.