Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Trapezoidal numerical integration

`Q = trapz(Y)`

`Q = trapz(X,Y)`

`Q = trapz(___,dim)`

`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.

Use

`trapz`

and`cumtrapz`

to perform numerical integrations on discrete data sets. Use`integral`

,`integral2`

, or`integral3`

instead if a functional expression for the data is available.`trapz`

reduces the size of the dimension it operates on to 1, and returns only the final integration value.`cumtrapz`

also returns the intermediate integration values, preserving the size of the dimension it operates on.

Was this topic helpful?