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 Comment

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,’

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 8 Jan 2017

Commented:

on 8 Jan 2017

Community Treasure Hunt

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

Start Hunting!