【问题标题】:How to put comment in a line-continuation [duplicate]如何将注释放在续行中[重复]
【发布时间】:2016-09-26 05:13:45
【问题描述】:

我有一些这样的功能:

result = myfunc(arg1, ...
                arg2, ...
                arg3);

我希望注释掉 arg2 并添加其他内容:

result = myfunc(arg1, ...
         %      arg2, ...    <-- I get a red squiggly underline at the last dot
                arg2b, ...   <-- and under arg2b
                arg3);       <-- and under the closing parenthesis

但是 matlab 不允许我在续行中添加注释,并且我所有的 Google 搜索都会出现多行语句或多行 cmets,但不会出现多行语句中的 cmets。

错误是“Parse error at : usage might be invalid Matlab syntax”。

有没有办法做到这一点?

实际上,参数是带有完整路径的长文件名,将它们向上移动会导致代码非常不可读。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    要注释掉跨越多行的语句的一部分,请使用省略号 (...) 而不是百分号。例如,

    result = myfunc(arg1, ...
                ... arg2, ...
                    arg2b, ...
                    arg3);
    

    【讨论】:

    • 如此简单,却又如此明显!!谢谢:)
    猜你喜欢
    • 2014-10-21
    • 2015-07-15
    • 2015-08-06
    • 1970-01-01
    • 2019-02-23
    • 2018-03-09
    • 2019-12-04
    • 1970-01-01
    • 2014-01-27
    相关资源
    最近更新 更多