I'm new on matlab.
How can I integrate this line of code ? ?
p2= polyfit(x,y,length(x));
from= x(1);
to= x(length(x));
I need the integration of p2.
I tried a lot with the Integration function:
value = integral(p2,from,to);
but I got
Error using integral (line 82) First input argument must be a function handle.
Error in poly_integral (line 5)
value = integral(p2,from,to);
That is because
p2, in your code, is not a function. It is just a vector of coefficients. The first argument forintegralneeds to be handle to the function that you want to integrate.Judging from your code, it seems that you would want to define a function that evaluates the polynomial
p2. If so, you could do something like the following example: