Finding the area under a polynomial equation in MATLAB
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
James Tursa
il 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 Commenti
James Tursa
il 30 Apr 2018
Modificato: James Tursa
il 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?
Categorie
Scopri di più su Descriptive Statistics and Insights in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

