how can Integrate polyfit in matlab ? ?

Hi , I have problem when i try to integrate polyfit in matlab and what I need to do is To fit the data (x and y are two vecore with the same file ) to a polynomial of degree n where n is the number of elements of x then integrate the polynomial analytically between the first and last values of x and assign this integral as I_analytical,
what i tried is this
p2= polyfit(x,y,length(x));
firstX = x(1);
LasttX = x(length(x));
value = integral(p2,firstX,LasttX);
but it didnt work correctly I got
Error in poly_integral (line 5)
value = integral(p2,from,to);
Any idea please ? ? ?

1 commentaire

Star Strider
Star Strider le 8 Jan 2017
My Answer:
‘See the documentation for the polyint (link) function. It will probably do what you want.’
Left Unsaid:
‘I can't ,I must do it like what it is above I have to fit the data to a polynomial of degree n where n is the number of elements of x, then integrate the polynomial analytically between the first and last values of x and assign this integral as I_analytical,’

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Polynomials dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by