User`s guide
fit
4-105
Example Fit the census data with a second-degree polynomial library model and return
the goodness of fit statistics and the output structure.
load census
[fit1,gof1,out1] = fit(cdate,pop,'poly2');
Normalize the data and fit with a third-degree polynomial.
[fit1,gof1,out1] = fit(cdate,pop,'poly3','Normalize','on');
Fit the data with a single-term exponential library model.
[fit2,gof2,out2] = fit(cdate,pop,'exp1','Normalize','on');
Create a fit options object, and try to find a better fit by overriding the default
starting points for the fit coefficients.
opts = fitoptions('exp1','Norm','on','start',[100 0.1]);
[fit3,gof3,out3] = fit(cdate,pop,'exp1',opts);
Fit the data to a custom model that contains the problem parameter n.
mymodel = fittype('a*exp(b*n*x)+c','problem','n');
opts = fitoptions(mymodel);
set(opts,'normalize','on')
[fit4,gof4,out4] = fit(cdate,pop,mymodel,opts,'problem',{2});
Warning: Start point not provided, choosing random start point.
The warning occurs whenever you fit data with a custom nonlinear model and
do not provide starting points.
See Also cflibhelp, fitoptions, fittype