trapz
Trapezoidal numerical integration.
📝Syntax
Z = trapz(Y)
Z = trapz(X, Y)
Z = trapz(Y, dim)
Z = trapz(X, Y, dim)
📥Input Arguments
Parameter Description
Y vector or matrix (real or single)
X point spacing: vector
dim dimension: positive integer scalar
📤Output Arguments
Parameter Description
Z integral: scalar, vector or matrix.
📄Description

trapz(Y) computes the approximate integral of Y using the trapezoidal method with unit spacing, along the first non-singleton dimension.

trapz(X, Y) integrates Y with respect to the coordinates given by X.

Use dim to integrate along a specific dimension.

💡Examples
x = 0:0.1:pi;
Z = trapz(x, sin(x))
🔗See Also
cumtrapzsum
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub