Main Content

coeffvalues

Coefficient values ofcfitorsfitobject

Description

example

coeffvals= coeffvalues(fun)returns the values of the coefficients, or parameters, of thecfitorsfitobjectfunas a 1-by-nvectorcoeffvals, wheren = numcoeffs(fun).

Examples

collapse all

Load the data in thecensus.matfile and construct afittypefor a quadratic polynomial curve.

loadcensusf = fittype('poly2');

Obtain the coefficient names and the formula for thefittypeobjectf.

coefficientNames = coeffnames(f)
coefficientNames =3x1 cell{'p1'} {'p2'} {'p3'}
formula(f)
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×3104× 0.0000 -0.0024 2.1130

Input Arguments

collapse all

Object of which you want to calculate the coefficients, specified as acfitorsfitobject.

Output Arguments

collapse all

Values of the coefficients of thecfitorsfitobjectfun, returned as a scalar or vector.

Introduced before R2006a