Main Content


Coefficient values of cfit or sfit object



coeffvals= coeffvalues(fun) returns the values of the coefficients, or parameters, of the cfit or sfit object fun as a 1-by-n vector coeffvals, where n = numcoeffs(fun).


collapse all

Load the data in the census.mat file and construct a fittype for a quadratic polynomial curve.

load census
f = fittype('poly2');

Obtain the coefficient names and the formula for the fittype object f.

coefficientNames = coeffnames(f)
coefficientNames = 3x1 cell

ans = 
'p1*x^2 + p2*x + p3'

Fit the curve to the data and retrieve the coefficient values.

c = fit(cdate,pop,f);
coefficientValues = coeffvalues(c)
coefficientValues = 1×3
104 ×

    0.0000   -0.0024    2.1130

Input Arguments

collapse all

Object of which you want to calculate the coefficients, specified as a cfit or sfit object.

Output Arguments

collapse all

Values of the coefficients of the cfit or sfit object fun, returned as a scalar or vector.

Version History

Introduced before R2006a