fittype - Constructor for fittype object

Syntax

ffun = fittype(libname)
ffun = fittype(expr)
ffun = fittype({expr1,...,exprn})
ffun = fittype(expr,PropName,PropVal,...)
ffun = fittype({expr1,...,exprn},PropName,PropVal,...)

Description

ffun = fittype(libname) constructs the fittype object ffun for the library model specified by libname. You can display library model names with the cflibhelp function.

ffun = fittype(expr) constructs the fittype object ffun for the custom nonlinear model specified by the expression in the string expr. By default, the independent variable is assumed to be x and the dependent variable is assumed to be y. All other variables are assumed to be coefficients. All coefficients must be scalars.

ffun = fittype({expr1,...,exprn}) constructs the fittype object ffun for the custom linear model with terms specified by the expressions in the strings expr1, expr2, ... , exprn. Coefficients are not included in the expressions for the terms. If there is a constant term, use '1' as the corresponding expression in the cell array.

ffun = fittype(expr,PropName,PropVal,...) or ffun = fittype({expr1,...,exprn},PropName,PropVal,...) constructs the fittype object ffun using specified property name/value pairs. Supported property names and values are given in the table below.

PropName

PropVal

'coefficients'

The coefficient names. Use a cell array if there are multiple names. The following names are not allowed: i, j, pi, inf, nan, eps.

'dependent'

The dependent (response) variable name

'independent'

The independent (predictor) variable name

'options'

The default fit options for the object

'problem'

The problem-dependent (fixed) parameter names. Use a cell array if there are multiple names. The default is none.

Example

Construct a fittype object for the rat33 library model:

f = fittype('rat33')
f =
   General model Rat33:
   f(p1,p2,p3,p4,q1,q2,q3,x) = 
         (p1*x^3 + p2*x^2 + p3*x + p4)/
                (x^3 + q1*x^2 + q2*x + q3)

Construct a fittype object for a custom nonlinear model, designating n as a problem-dependent parameter and u as the independent variable:

g = fittype('a*u+b*exp(n*u)',...
            'problem','n',...
            'independent','u')
g =
     General model:
       g(a,b,n,u) = a*u+b*exp(n*u)

Construct a fittype object for a custom linear model, specifying the names of the coefficients:

h = fittype({'cos(x)','1'},'coefficients',{'a1','a2'})
h =
     Linear model:
       h(a1,a2,x) = a1*cos(x) + a2

See Also

fit, cfit

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS