Finding the area under a polynomial equation in MATLAB
Show older comments
Hi. I have two vectors like these.
X=[0 0.0300 0.0333 0.0469 0.0575 0.0649 0.0960 0.1262 0.1610 0.1717 0.2017 0.2411 0.2711 0.3000 0.3035 0.3368 0.3711 0.4068 0.4411 0.4758 0.5253 0.5553 0.5853 0.6000]
Y=[0 126.2766 140.0068 190.5906 211.6557 219.3601 236.8709 253.2271 266.4663 269.3085 273.6913 279.3095 283.5479 286.1191 286.2725 282.7424 277.6845 272.1010 266.4556 260.1458 248.5416 241.1381 233.2857 230.3781]
I use the polyfit command to fit a polynomial curve of degree 6 to my data-set.
B=polyfit(X,Y,6)
Now my question is how can I calculate the area under this polynomial curve?
Thanks a lot.
Accepted Answer
More Answers (1)
James Tursa
on 30 Apr 2018
Just integrate the polynomial and evaluate at the endpoints. E.g.,
IB = polyint(B);
area_under_poly = polyval(IB,X(end)) - polyval(IB,X(1));
3 Comments
James Tursa
on 30 Apr 2018
Edited: James Tursa
on 30 Apr 2018
By hand (using the fact that x(1)=0):
>> (1/3)*B(1)*x(end)^3 + (1/2)*B(2)*x(end)^2 + B(3)*x(end)
ans =
112.5000
Why do you think the answer must be 102.5?
Categories
Find more on Descriptive Statistics and Insights in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
