主要内容

MATLAB代码兼容性分析仪

代码兼容性分析仪是一个方便的工具,可分析您的代码,列出表格格式的整个兼容性问题,并为您提供有关如何解决这些兼容性问题的说明。该报告使您能够:

  • 确定您必须解决代码必须在当前MATLAB中正确运行的兼容性问题®发布。

  • 估算升级到较新的MATLAB版本时更新代码所需的精力。

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

代码兼容性分析仪显示您的代码中的位置,这些位置受兼容性问题的影响,并提供了文档的链接,以获取有关如何在每个位置进行必要更改的更多信息。

打开代码兼容性分析仪

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. In the Current Folder browser that lists the files you want to analyze, either click或在浏览器的空白处右键单击。这两个选项打开菜单。选择Reports>代码兼容性报告。Alternatively, you can runCodeCompatibilityReport在命令提示下生成报告或选择代码兼容性分析仪来自应用标签。

    The report displays in the MATLAB Web Browser, showing potential compatibility issues. For example:

    代码兼容性分析仪应用程序

  3. 更新您的代码以解决在此中列出的每个文件的语法错误语法错误部分。语法错误导致无法运行的代码。尽管最有可能在以前的版本中无法正确运行该代码,但语法错误会影响兼容性分析。例如,Parse error at '}': usage might be invalid MATLAB syntax

  4. 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文档与消息关联的链接。

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

    • Functionality that has been removed- 更新您的代码,以避免当前版本中的兼容性错误。

    • 改变行为的功能— Confirm that the change in behavior is acceptable, and if not, update your code for the current release.

    • 可能万博1manbetx导致错误的无支撑功能— 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.

    • 将删除的功能- 立即或以后版本更新您的代码。现在更新代码使以后的升级更加容易。

    • 会改变行为的功能- 现在调查这些更改,以使将来的升级更加容易。

    • 可能改善代码的新功能- 考虑更新您的代码。当前的代码预计将继续在将来的发行版中工作,但建议使用较新的功能。

    代码兼容性分析仪还包括有关代码上执行的检查以及MATLAB分析代码兼容性的文件列表的信息。

程序化使用

当您生成代码兼容性分析仪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.

  • 要生成一份报告,该报告以编程方式在MATLAB®Web浏览器中打开,请使用CodeCompatibilityAnalyzer并指定要分析的文件夹。

  • 要生成当前文件夹及其子文件夹的报告,请使用CodeCompatibilityReport功能。

  • 返回CodeCompatibilityAnalysis包含报告信息的对象,使用分析兼容性功能。You can then display a report for the stored object using theCodeCompatibilityReport功能。

不支万博1manbetx持的功能

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. ContactMathworks支万博1manbetx持描述您的使用情况并请求支持的替换。万博1manbetx

也可以看看

|||