FreeMat
TRAPZ Trapezoidal Rule Integration

Section: Numerical Methods

Usage

The trapz routine has the following syntax @[ z = trapz(x,y) @] where |x| is a dependent vector and |y| an m-by-n matrix equal in at least one dimension to x. (e.g.:|x| = time samples, y = f(t))

Alternatively, you can enter

     z = trapz(y) 

for a unit integration of y.

If y is a matrix, m must be equal to length(x) (e.g.: y must have the same number of rows as x has elements). In this case, integrals are taken for each row, returned in a resulting vector z of dimension (1,n)