Trapezoidal numerical integration(梯形数值积分)

**1. Trapezoidal numerical integration(梯形数值积分)

1. Principle*

【trapz】performs numerical integration via the trapezoidal method. This method approximates the integration over an interval by breaking the area down into trapezoids with more easily computable areas. For example, here is a trapezoidal integration of the sine function using eight evenly-spaced trapezoids:

梯形数值积分原理图

2. Formula

a) the constant spacing model
等间距模型

b) General model
在这里插入图片描述

Q = trapz(Y) computes the approximate integral of 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.

Q = trapz(X,Y) integrates Y with respect to the coordinates or scalar spacing specified by X.

  • If X is a vector of coordinates, then length(X) must be equal to the
    size of the first dimension of Y whose size does not equal 1.
  • If X is a scalar spacing, then trapz(X,Y) is equivalent to
    X*trapz(Y).

典例

Integrate Vector of Data with Unit Spacing
Calculate the integral of a vector where the spacing between data points is 1.

Create a numeric vector of data.
Y = [1 4 9 16 25];
Y contains function values for in the domain [1, 5].

Use trapz to integrate the data with unit spacing.
Q = trapz(Y)
This approximate integration yields a value of 42. In this case, the exact answer is a little less, . The trapz function overestimates the value of the integral because f(x) is concave up.
Copyright 2012 The MathWorks, Inc.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值