在大型脚本中查找未压缩的行

Bal*_*yal 1 matlab

我正在运行一个相当大的脚本.在输出屏幕中我得到ans = 10.

问题是代码非常大,我无法确定此输出来自何处.

是否有任何提示可以在MATLAB环境中找到此输出的来源,因为我不希望屏幕上有随机输出?

Dev*_*-iL 6

对于单个脚本文件,您可以以编程方式调用mlint以以下形式返回所有警告struct:

L = mlint('my_filename'); % No need for .m at the end
Run Code Online (Sandbox Code Playgroud)

检查结构,您可以看到以下内容:

变量编辑器

这个结构有一个名为'message'包含各种问题的字段,其中包括我们所追求的 - 'Terminate statement with semicolon to suppress output (in functions).'.在这个阶段你可以运行

find( strcmp({L.message},... % output is not suppressed on purpose
     'Terminate statement with semicolon to suppress output (in functions).') ) 
Run Code Online (Sandbox Code Playgroud)

然后检查打印的行号.

或者,如果要跳过变量编辑器,或者想要检查整个文件夹.m,可以运行mlintrpt(在文件夹的情况下)或mlintrpt('plotWithoutOutliers')(在单个文件的情况下)并以下面的形式获取报告:

mlintrpt输出