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.
Open the Code Compatibility Analyzer
To run the Code Compatibility Analyzer:
In the Current Folder browser, navigate to and open the folder that contains the code files you want to analyze.
In the Current Folder browser that lists the files you want to analyze, either click or right-click in the white space of the browser. Both options open a menu. Select Reports > Code Compatibility Report. Alternatively, you can run
codeCompatibilityReportat the command prompt to generate the report or select Code Compatibility Analyzer from the Apps tab.
The report displays in the MATLAB Web Browser, showing potential compatibility issues. For example:
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, Parse error at '}': usage might be invalid MATLAB syntax.
For each functionality listed in the report, 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 Documentation 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.
When you generate a Code Compatibility Analyzer through the current folder browser, MATLAB analyzes code in the current working folder and subfolders. However, if you generate a report programmatically, you can specify particular files to analyze or to exclude subfolders from analysis. To generate a report programmatically, use one of the following methods.
To generate a report that opens in the MATLAB® Web Browser programmatically, use
codeCompatibilityAnalyzerand specify the folder you wish to analyze.
To generate a report for the current folder and it's subfolders, use the
To return a
CodeCompatibilityAnalysisobject that contains the report information, use the
analyzeCodeCompatibilityfunction. You can then display a report for the stored object using the
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.