Vector integration; is this the most correct and/or accurate calculation?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Stuart Hobson
am 13 Aug. 2019
Kommentiert: Stuart Hobson
am 14 Aug. 2019
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))
1 Kommentar
Akzeptierte Antwort
John D'Errico
am 14 Aug. 2019
Bearbeitet: John D'Errico
am 14 Aug. 2019
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!