Vector integration; is this the most correct and/or accurate calculation?

5 次查看(过去 30 天)
Good day,
this seems to be a regular question topic; I unfortunately am not sure I have the correct understanding from the help files or description of the use of trapz.
I have a vector 'time' with a series of non-uniformly spaced time data points.
I have vectors 'P' and 'At' which are independant data points known at each specific time.
So I want to calculate the integral of (P x At dtime).
Is the correct use and/or most accurate use of trapz in this regard as follows:
Cstar_eff = trapz(time,(P.*At))

采纳的回答

John D'Errico
John D'Errico 2019-8-14
编辑:John D'Errico 2019-8-14
This is a slightly complex question.
Is it the correct use of trapz? Of course.
Is it the most accurate possible way to integrate a data series? It is just trapezoidal rule, for god sakes. Trapezoidal rule is a good choice if there is any noise at all in your data. Higher order rules tend to amplify any noise, whereas trapezoidal rule is about as good as you can get in terms of not amplifying any noise, so it can be a minimum variance estimator, unless you need to use smoothing.
However, if your series represents a very smooth kernel, then trapezoidal rule may not be the best choice. You would be better off using a higher order rule. Perhaps a higher order Newton Cotes rule (Simpson's rule is the simple example that you might have heard of.) Or you could interpolate the points using a spline, then integrate the spline.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by