This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Integrate cfit object


int = integrate(fun,x,x0)


int = integrate(fun,x,x0) integrates the cfit object fun at the points specified by the vector x, starting from x0, and returns the result in int. int is a vector the same size as x. x0 is a scalar.


Create a baseline sinusoidal signal:

xdata = (0:.1:2*pi)';
y0 = sin(xdata);

Add response-dependent Gaussian noise to the signal:

noise = 2*y0.*randn(size(y0));
ydata = y0 + noise;

Fit the noisy data with a custom sinusoidal model:

f = fittype('a*sin(b*x)');
fit1 = fit(xdata,ydata,f,'StartPoint',[1 1]);

Find the integral of the fit at the predictors:

int = integrate(fit1,xdata,0);

Plot the data, the fit, and the integral:

plot(fit1,xdata,ydata) % cfit plot method
plot(xdata,int,'m') % double plot method
grid on

Note that integrals can also be computed and plotted directly with the cfit plot method, as follows:


The plot method, however, does not return data on the integral.

See Also

| |

Introduced before R2006a