cumtrapz

Cumulative numerical integration of discrete data using the trapezoid rule.

Syntax

area=cumtrapz(y)

area=cumtrapz(x,y)

area=cumtrapz(...,dim)

Inputs

x
Values of the domain variable.
When omitted, a vector with unit increments is supplied.
Type: double
Dimension: vector
y
Values of the range variable.
Type: double
Dimension: vector | matrix
dim
The dimension on which to integrate.
Default: first non-singleton dimension.
Type: integer
Dimension: scalar

Outputs

area
The estimated cumulative area.
Dimension: scalar | matrix

Example

x = [0:0.1:1]*pi; area = cumtrapz(x,sin(x))
area = [Matrix] 1 x 11 0.00000 0.04854 0.18941 0.40882 0.68529 0.99176 1.29823 1.57470 1.79411 1.93498 1.98352

Comments

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