Trapezoidal numerical integration

`Q = trapz(`

returns
the approximate integral of `Y`

)`Y`

via the trapezoidal method with
unit spacing. The size of `Y`

determines the dimension
to integrate along:

If

`Y`

is a vector, then`trapz(Y)`

is the approximate integral of`Y`

.If

`Y`

is a matrix, then`trapz(Y)`

integrates over each column and returns a row vector of integration values.If

`Y`

is a multidimensional array, then`trapz(Y)`

integrates over the first dimension whose size does not equal 1. The size of this dimension becomes 1, and the sizes of other dimensions remain unchanged.

Was this topic helpful?