使用Simpson规则对离散数据进行数值积分 [英] Numerical integration using Simpson's Rule on discrete data

查看:486
本文介绍了使用Simpson规则对离散数据进行数值积分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找与matlab进行数值积分的方法.我知道在matlab中有一个trapz函数,但是精度不够好.通过在线搜索,我发现有一个四元函数,它似乎只接受符号表达式作为输入.我的数据都是离散的和一维的.有什么办法在我的数据上使用四边形吗?谢谢.

I am looking for numerical integration with matlab. I know that there is a trapz function in matlab but the precision is not good enough. By searching it online, I found there is a quad function there it seems only accept symbolic expression as input. My data is all discrete and one-dimensional. Is that any way to use quad on my data? Thanks.

推荐答案

您的问题的答案为否.在Matlab中对没有表达式的数据执行数值积分的唯一方法是使用trapz函数.如果对您来说不够准确,请尝试编写自己的四元函数,如Li-aung所说,这非常简单,可能有帮助.

An answer to your question would be no. The only way to perform numerical integration for data with no expression in Matlab is by using the trapz function. If it's not accurate enough for you, try writing your own quad function as Li-aung said, it's very simple, this may help.

您可以尝试的另一种方法是使用功能强大的曲线拟合工具cftool进行拟合,然后使用可以对cfit对象进行操作的integrate函数(它有一个怪异的约定,上限是第一个论点!).我认为您不会得到比trapz更准确的答案,这取决于适合程度.

Another method you may try is to use the powerful Curve Fitting Tool cftool to make a fit then use the integrate function which can operate on cfit objects (it has a weird convention, the upper limit is the first argument!). I don't think you will get much accurate answers than trapz, it depends on the fit.

这篇关于使用Simpson规则对离散数据进行数值积分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆