MATLAB: Integrating equations obtained from polyfit

polyfit

Hello,
I have an equation to integrate:
exp(thata(x)-1)*y_f(x)
But I used polyfit to get the theta and the y_f, so i have two vectors. but I want the equation version of the fit, so that I can put it on the integral equation. how can i use those two vectors to be able to compute that integral?
If someone knows how to do this, I'd appreciate the help!
thank you

Best Answer

Well, either you can hope that your function exp(theta(x)-1)*f(x) has an explicit integral (which might be a stretch) and build yourself a symbolic version of the function and then try the integration-power of the symbolic toolbox. Or you could go with matlabs quadrature functions:
quadgk(@(x) exp(polyval(theta_p,x)-1).*polyval(f,x),0,x_star)
That should work provided your function isn't too obscure.
HTH