【问题标题】:Can we add a statement in between MATLAB codes?我们可以在 MATLAB 代码之间添加语句吗?
【发布时间】:2015-08-30 10:01:56
【问题描述】:

是否可以在代码之间添加语句。
例如:如果我有这样的代码,

r(:,1) = a(:,1) - a(:,2);

那我可以写成,

r(:,1) = a(:,1)("this is a constant") - a(:,2)("this is a variable");

【问题讨论】:

标签: matlab


【解决方案1】:

作为对 sudomakeinstall2

非常正确答案的补充

在其他编程语言中,例如Java 你可以做类似的事情

myvar = 1 + /* some comment here */ 5;

尽管 MATLAB 知道与 %{%} 结尾的类似内容,它们仅适用于多行 cmets,所以最后,sudomakeinstall2s 的答案是我能想到的最好的答案。

【讨论】:

    【解决方案2】:

    你需要像这样评论那些陈述

    r(:,1) = a(:,1) ... % this is a constant 
             - a(:,2); % this is a variable 
    

    更多信息请阅读this

    【讨论】:

      猜你喜欢
      • 2023-03-04
      • 1970-01-01
      • 2020-10-15
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 2019-07-23
      相关资源
      最近更新 更多