Method on @sym: sum (x)
Method on @sym: sum (x, n)

Sum of symbolic expressions.

Sum over the rows or columns of an expression. By default, sum over the rows. Can specify row or column sums using n. To perform symbolic summations, see ‘@sym/symsum’.

Examples:

syms x y z
sum([x y z])
  ⇒ (sym) x + y + z

sum([x y; x z], 1)
  ⇒ (sym) [2⋅x  y + z]  (1×2 matrix)

sum([x y; x z], 2)
  ⇒ (sym 2×1 matrix)
      ⎡x + y⎤
      ⎢     ⎥
      ⎣x + z⎦

See also: @sym/prod, @sym/symsum.

Package: symbolic