sum

description:

s = sum(A,dim) is sum of the elements. For vectors, sum(A) is the sum of the elements of A. For matrices, sum(A) or sum(A,1) is a row vector of column sums and sum(A,2) is a column vector of row sums.

arguments:

A is a matrix of NCpolys

dim tells if it is a column (1) or row (2) sum; for matrices is default 1

output:

row/column of NCpolys

possible usage:

sum(A), sum(A,dim)

example

>> v=[x x+y y];

>> sum(v)

ans = 2*x+2*y

>> A=[x x+y y; x-y y x+y];

>> sum(A)

ans = 2*x-y   x+2*y   x+2*y

>> sum(A,2)

ans = 2*x+2*y

        2*x+y