如何在 MATLAB 中显示静态分析警告?
How to display static analysis warnings in MATLAB?
我注意到 MATLAB 编辑器经常会针对“.m”文件显示非常有用的警告。因为我倾向于远程 运行 我的 MATLAB 代码,所以我不喜欢使用 MATLAB 编辑器,而是保持打开一个很长的 运行ning emacs 会话。如果这些警告可以在 运行 脚本时打印出来,也许如果启用了某些设置(我可以想象不想默认这样做以提高性能),那就太好了。这可能吗?
我相信您正在寻找 checkcode
。来自文档:
checkcode(filename)
displays messages about filename
that report potential problems and opportunities for code improvement. These messages are sometimes referred to as Code Analyzer messages. The line number in the message is a hyperlink that you can click to go directly to that line in the Editor. The exact text of the checkcode
messages is subject to some change between versions.
...
info = checkcode(___,'-struct')
returns the information as an n
-by-1
structure array, where n
is the number of messages found.
我注意到 MATLAB 编辑器经常会针对“.m”文件显示非常有用的警告。因为我倾向于远程 运行 我的 MATLAB 代码,所以我不喜欢使用 MATLAB 编辑器,而是保持打开一个很长的 运行ning emacs 会话。如果这些警告可以在 运行 脚本时打印出来,也许如果启用了某些设置(我可以想象不想默认这样做以提高性能),那就太好了。这可能吗?
我相信您正在寻找 checkcode
。来自文档:
checkcode(filename)
displays messages aboutfilename
that report potential problems and opportunities for code improvement. These messages are sometimes referred to as Code Analyzer messages. The line number in the message is a hyperlink that you can click to go directly to that line in the Editor. The exact text of thecheckcode
messages is subject to some change between versions....
info = checkcode(___,'-struct')
returns the information as ann
-by-1
structure array, wheren
is the number of messages found.