【问题标题】:matlab based program where output comprises of sum of rows of input基于 matlab 的程序,其中输出包括输入行的总和
【发布时间】:2013-03-04 06:15:31
【问题描述】:

让给定的矩阵为:

  c=[5.24 5.19 5.07 4.36;
     5.39 5.44 5.38 5.32;
     5.58 5.12 6.05 4.02]

我想计算输出矩阵,使得输出矩阵的第一行是 c 的第一行,然后输出矩阵的第二行是 c 的前两行的总和,第三行是 c 的三行的总和.如何为此编写matlab代码。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    使用Matlab的cumulative sum函数:

    ans = cumsum(c);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-03
      • 2015-12-27
      • 1970-01-01
      • 1970-01-01
      • 2023-01-12
      • 1970-01-01
      • 2021-02-14
      • 2019-07-16
      相关资源
      最近更新 更多