matlabcurve-fittingnumerical-integrationdifferentiation

Double Integration of a custom equation by fit() Matlab


Is it possible to double integrate a function that is a result of a fit() (the type of function is cfit).

The differentiation is easy using the following function differentiate(myfit,points);

While Integration using integrate(myfit,points,start); results in the integral as a set of values at the points location. Is there a function in matlab that returns another function similar to differentiate()?

Thanks!


Solution

  • Try to use this:

    f = fit(xdata, ydata,'cubicinterp');
    % function integration
    I1 = fit(xdata, integrate(f,xdata,0),'cubicinterp');
    % double integration
    integrate(I1,xdata,0)
    

    where xdata is the argument of the function ydata.