Method on @sym: cumsum (x)
Method on @sym: cumsum (x, dim)

Cumulative sum over the rows or columns of a symbolic array.

If dim is omitted, it defaults to the first non-singleton dimension. For example:

Examples:

t = sym ('t');
Pi = sym ('pi');
T = [t; t + Pi / 2; t + Pi; t + 3 * Pi / 2; t + 2 * Pi];
C = cos (T);
cumsum (C)
  ⇒ (sym 5×1 matrix)
      ⎡     cos(t)     ⎤
      ⎢                ⎥
      ⎢-sin(t) + cos(t)⎥
      ⎢                ⎥
      ⎢    -sin(t)     ⎥
      ⎢                ⎥
      ⎢       0        ⎥
      ⎢                ⎥
      ⎣     cos(t)     ⎦

Specify dimension along which to sum:

X = repmat (sym ('x'), 2, 3);

cumsum (X, 1)
  ⇒ (sym 2×3 matrix)
      ⎡ x    x    x ⎤
      ⎢             ⎥
      ⎣2⋅x  2⋅x  2⋅x⎦

cumsum (X, 2)
  ⇒ (sym 2×3 matrix)
      ⎡x  2⋅x  3⋅x⎤
      ⎢           ⎥
      ⎣x  2⋅x  3⋅x⎦

See also: @sym/sum, @sym/cumprod.

Package: symbolic