Main Content

MATLAB Code Compatibility Analyzer

The Code Compatibility Analyzer is a convenient tool that analyzes your code, lists the entire set of compatibility issues in tabular format, and provides you with instructions on how to address these compatibility issues. The report enables you to:

  • Identify the compatibility issues that you must address for your code to run properly in the current MATLAB® release.

  • Estimate the effort required to update your code when you upgrade to a newer MATLAB release.

  • Improve your code by replacing functionality that is not recommended.

The Code Compatibility Analyzer displays the locations in your code that are affected by compatibility issues and provides links to the documentation for more information on how to make the necessary changes at each location.

A list of all checks performed by the MATLAB Code Analyzer, including compatibility issues, can be found here, Index of Code Analyzer Checks.

Open the Code Compatibility Analyzer

To run the Code Compatibility Analyzer:

  1. In the Current Folder browser, navigate to and open the folder that contains the code files you want to analyze.

  2. Run codeCompatibilityReport at the command prompt to generate the report or select Code Compatibility Analyzer Icon of Code Compatibility App from the Apps tab.

    The report shows potential compatibility issues. For example:

    Code Compatibility Analyzer App

  3. Update your code to resolve the syntax errors for each file listed in the Syntax Errors section. Syntax errors result in code that does not run. While most likely the code did not run properly in previous releases, syntax errors impact compatibility analysis. For example, A '(' might be missing a closing ')', causing invalid syntax at end of line (1)..

  4. For each functionality listed in the report, click the expander to the left of the row review the issue description and your code. Messages include the line numbers to help locate the issue in your code. To open the file in the Editor at that line, click the line number. Then change the file based on the message. If you are unsure what a message means or what to change in the code, click the Help link associated with the message.

    Each functionality listed in the report displays a recommended action. You also can use the following general advice:

    • Functionality that has been removed — Update your code to avoid compatibility errors in the current release.

    • Functionality that has changed behavior — Confirm that the change in behavior is acceptable, and if not, update your code for the current release.

    • Unsupported functionality that might cause errors — Files listed here use functionality that is unsupported, undocumented, and not intended for customer use. Update your code to use documented functionality to avoid errors and unexpected behavior changes.

    • Functionality that will be removed — Update your code now or in a later release. Updating your code now makes future upgrades easier.

    • Functionality that will change behavior — Investigate these changes now to make future upgrades easier.

    • New functionality that might improve code — Consider updating your code. Current code is expected to continue working in future releases but newer functionality is recommended.

    The Code Compatibility Analyzer also includes information about the checks performed on your code and the list of files that MATLAB analyzed for code compatibility.

Programmatic Use

To generate a report programmatically, use one of the following methods.

  • To generate a report that opens in the MATLAB® Web Browser programmatically, use codeCompatibilityAnalyzer and specify the folder you wish to analyze.

  • To generate a report for the current folder and its subfolders, use the codeCompatibilityReport function.

  • To return a CodeCompatibilityAnalysis object that contains the report information, use the analyzeCodeCompatibility function. You can then display a report for the stored object using the codeCompatibilityReport function.

Unsupported Functionality

The Code Compatibility Analyzer checks for functionality that is unsupported, undocumented, and not intended for use. Such features are subject to change or removal without notice and can cause future errors. In some cases there is documented replacement functionality, but there might be no simple replacement. Contact MathWorks Support to describe your usage and request supported replacement.

See Also

| | |