trapz

Numerical integration of discrete data using the trapezoid rule.

Syntax

area=trapz(x,y)

Inputs

x
Values of the domain variable.
Type: double
Dimension: vector
y
Values of the range variable.
Type: double
Dimension: vector

Outputs

area
The estimated area.
Dimension: scalar | matrix

Example

x = [0:0.05:1]*pi; area = trapz(x,sin(x))
area = 1.99588597

Comments

trapz is appropriate for use with sampled data when the function is not available.