Main Content

fitoptions

创建或修改拟合选项对象

描述

例子

fitoptions= fitoptions创建默认拟合选项对象fitoptions

例子

fitoptions= fitoptions(LibraryModelName为库模型创建默认拟合选项对象。

例子

fitoptions= fitoptions(LibraryModelName,,,,名称,价值为指定库模型创建适合选项,并使用一个或多个指定的其他选项名称,价值pair arguments.

例子

fitoptions= fitoptions(合身Type获取指定的拟合选项对象合身Type。使用此语法来适用于自定义模型的合适选项。

例子

fitoptions= fitoptions(名称,价值使用一个或多个指定的其他选项创建适合选项名称,价值pair arguments.

例子

纽约= fitoptions(fitoptions,,,,名称,价值修改现有拟合选项对象fitoptions和returns updated fit options in纽约有一个或多个指定的新选项名称,价值pair arguments.

例子

纽约= fitoptions(选项1,,,,选项2结合现有拟合选项对象选项1选项2纽约

  • 如果方法同意,在选项2覆盖相应的值选项1纽约

  • 如果方法不同,纽约包含选项1value for方法和来自选项2为了Normalize,,,,排除, 和权重

例子

全部收缩

创建默认拟合选项对象,并在拟合前设置选项以中心和扩展数据。

选项= fitOptions;options.normal ='上'
options = Normalize: 'on' Exclude: [1x0 double] Weights: [1x0 double] Method: 'None'
选项= FitOptions('gauss2'
options = normorize:'off'排除:[]权重:[]方法:'nonelearleastsquares'robust:'Off'''开始点:[1x0 double]下部:[-inf -inf -inf -inf 0 -Inf -inf -Inf 0] upper:[1x0 double double]算法:“信任区” diffminchange:1.0000e-08 diffmaxchange:0.1000显示:'notify'maxfunevals:600 maxiter:400 tolfun:1.0000e-06 tolx:1.0000e-066

Create fit options for a cubic polynomial and set center and scale and robust fitting options.

选项= FitOptions('poly3',,,,“正常化”,,,,'上',,,,'强大的',,,,'Bisquare'
选择=正常化:‘上’排除:[]权重:[]方法: 'LinearLeastSquares' Robust: 'Bisquare' Lower: [1x0 double] Upper: [1x0 double]
选项= FitOptions('方法',,,,“线性阵线”
选项=归一化:'OFF'排除:[]权重:[]方法:'linearleastsquares'ronust:'off''''''':[1x0 double] upper:[1x0 double]

当您要设置默认拟合选项对象是有用的Normalize,,,,排除, 或者权重属性,然后使用具有不同拟合方法的相同选项适合您的数据。例如,以下使用相同的拟合选项来拟合不同的库模型类型。

加载人口普查选项= fitOptions;options.normalize ='上';f1 = fit(cdate,pop,'poly3',选项);f2 = fit(cdate,pop,'exp1',选项);f3 = fit(cdate,pop,“立方普林”,选项)
F3 =立方插值样条:F3(X)=从P计算的分段多项式,其中X通过平均值1890和STD 62.05系数归一化:P =系数结构

找到平滑参数。数据依赖性拟合选项,例如smooth参数在第三个输出参数中返回合身功能。

加载人口普查[f,gof,out] = fit(cdate,pop,'SmoothingSpline');SmoothParam = out.p
SmoothParam = 0.0089

修改新拟合的默认平滑参数。

选项= FitOptions('方法',,,,'SmoothingSpline',,,,...“平滑帕拉姆”,0.0098);[f,gof,out] = fit(cdate,pop,'SmoothingSpline',选项);

创建高斯拟合,检查置信区间,并指定下限拟合选项以帮助算法。

创建一个两个高斯峰的嘈杂总和,一个宽度较小,一个宽度很大。

A1 = 1;B1 = -1;C1 = 0.05;A2 = 1;B2 = 1;C2 = 50;x =(-10:0.02:10)';gdata = a1*exp( - (((x-b1)/c1)。^2) +...a2*exp( - ((x-b2)/c2)。^2) +...0.1*(rand(size(x))-.5); plot(x,gdata)

图包含一个轴对象。轴对象包含一个类型行的对象。

使用两项高斯库模型拟合数据。

gfit = fit(x,gdata,'gauss2'
gfit =常规模型高斯2:gfit(x)= a1*exp( - (((x-b1)/c1)^2) + a2*exp( - (((x-b2)/c2)^2)系数(带95% confidence bounds): a1 = -0.1451 (-1.485, 1.195) b1 = 9.725 (-14.7, 34.15) c1 = 7.117 (-15.84, 30.07) a2 = 14.08 (-1.962e+04, 1.965e+04) b2 = 607.4 (-3.197e+05, 3.209e+05) c2 = 376 (-9.745e+04, 9.82e+04)
情节(GFIT,X,GDATA)

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象表示数据,拟合曲线。

该算法有困难,如多个系数的宽敞置信区间所示。

为了帮助算法,为非负振幅指定下限a1a2和宽度C1,,,,C2

选项= FitOptions('gauss2',,,,'降低',[0 -Inf 0 0 -Inf 0]);

另外,您可以使用表单设置拟合选项的属性options.property = newPropertyValue

选项= FitOptions('gauss2');options.Lower = [0 -Inf 0 0 -Inf 0];

使用系数上的结合约束重新计算拟合。

gfit = fit(x,gdata,'gauss2',选项)
gfit =常规模型高斯2:gfit(x)= a1*exp( - (((x-b1)/c1)^2) + a2*exp( - (((x-b2)/c2)^2)系数(带95%置信度范围):A1 = 1.005(0.966,1.044)B1 = -1(-1.002,-0.9988)C1 = 0.0491(0.0469,0.0513)A2 = 0.9985(0.9958,1.001)B2 = 0.8059(0.8059(0.8059)(0.8059(0.8059)50.6(46.68,54.52)
情节(GFIT,X,GDATA)

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象表示数据,拟合曲线。

这是一个更好的选择。您可以通过将合理的值分配给拟合选项对象中的其他属性来进一步改善拟合。

创建拟合选项并设置下限。

选项= FitOptions('gauss2',,,,'降低',[0 -Inf 0 0 -Inf 0])
options = normorize:'off'排除:[]权重:[]方法:'nonelearleastsquares'rounst:'Off'''startpoint:[1x0 double]下部:[0 -Inf 0 0 -inf 0 -Inf 0] upper:[1x0 double]算法:'Trust-Region'DiffminChange:1.0000E-08 DIFFMAXCHANGE:0.1000显示:'Notify'MaxFuneVals:600 Maxiter:400 TOLFUN:1.0000E-06 TOLX:1.0000E-06

Make a new copy of the fit options and modify the robust parameter.

newoptions = fitoptions(选项,'强大的',,,,'Bisquare'
newoptions = normalize:'off'排除:[]权重:[]方法:'nonelearleastsquares'robust:'Bisquare'startpoint:[1x0 double]下部:[0 -Inf 0 0 -inf 0 -inf 0] upper:[1x0 double] algorithm:'Trust-Region'DiffminChange:1.0000E-08 DIFFMAXCHANGE:0.1000显示:'Notify'MaxFuneVals:600 Maxiter:400 TOLFUN:1.0000E-06 TOLX:1.0000E-06

结合拟合选择。

options2 = fitoptions(选项,newoptions)
options2 = normalize:'off'排除:[]权重:[]方法:'nonlinearleastsquares'rounst:'Bisquare'startpoint:[1x0 double]下部:[0 -Inf 0 0 -inf 0 -inf 0] upper:[1x0 double] algorithm:'Trust-Region'DiffminChange:1.0000E-08 DIFFMAXCHANGE:0.1000显示:'Notify'MaxFuneVals:600 Maxiter:400 TOLFUN:1.0000E-06 TOLX:1.0000E-06

创建线性模型拟合类型。

lft= fittype({'X',,,,'罪(x)',,,,'1'})
lft =线性模型:lft(a,b,c,x)= a*x + b*sin(x) + c

获取合适类型的合适选择lft

fo = fitoptions(lft)
fo =归一化:'OFF'排除:[]权重:[]方法:'linearleastsquares'rounst:'off''''''':[1x0 double] upper:[1x0 double]

设置标准化拟合选项。

fo.no​​rmorize ='上'
fo =归一化:'on'ublede:[]权重:[]方法:'linearleastsquares'rounst:'off'''''''':[1x0 double] upper:[1x0 double]

输入参数

全部收缩

适合的库模型,指定为字符向量或字符串标量。该表显示了一些常见的示例。

库模型名称

描述

'poly1'

线性多项式曲线

'poly11'

线性多项式表面

'poly2'

二次多项式曲线

'LinearInterp'

分段线性插值

'cubicinterp'

Piecewise cubic interpolation

“平滑线”

平滑样条(曲线)

'lowess'

局部线性回归(表面)

有关库名称列表,请参见模型名称和方程式

Example:'poly2'

数据类型:char|细绳

适合的模型类型,指定为FittypeFittype功能。使用此功能与自定义模型的合适选项一起使用。

算法选项,指定为fitoptions使用fitoptions功能。

组合算法选项,,,,constructed using thefitoptions功能。

组合算法选项,,,,constructed using thefitoptions功能。

名称值参数

将可选的参数对name1 = value1,...,namen = valuen, 在哪里姓名是参数名称和价值是the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

在R2021a之前,请使用逗号分隔每个名称和值,并附上姓名用引号。

Example:“方法”,“ nonelearleastsquares','soulter',[0,0],'upper',[inf,max(x)],'startpoint',[1 1]specifies fitting method, bounds, and start points.

所有拟合方法的选项

全部收缩

选项中心和扩展数据,该数据指定为逗号分隔对“正常化”'上'或者'off'

数据类型:char

从拟合中排除的点,指定为逗号分隔对'Exclude'还有一个:

  • An expression describing a logical vector, e.g.,x> 10

  • 整数向量索引要排除的要点,例如[1 10 25]

  • 所有数据点的逻辑向量真的represents an outlier, created by排除室

有关示例,请参见合身

权重为了the fit, specified as the comma-separated pair consisting of“重量”矢量与数据点数量相同。

数据类型:双倍的

拟合方法,指定为逗号分隔对,由'方法'和one of the fitting methods in this table.

拟合方法

描述

“最近的人”

最近的邻居插值

“线性插值”

线性插值

'PchipInterpolant'

分段立方赫米特插值(仅曲线)

“ Cubicsplineinterpolant”

立方样条插值

“ Biharmonicinterpolant”

Biharmonic surface interpolation

'SmoothingSpline'

平滑样条

'lowessfit'

降低平滑(仅表面)

“线性阵线”

线性最小二乘

“ nonelearleastsquares”

Nonlinear least squares

数据类型:char|细绳

平滑选项

全部收缩

平滑参数,,,,specified as the comma-separated pair consisting of“平滑帕拉姆”和0到1之间的标量值。默认值取决于数据集。仅当方法平滑图

数据类型:双倍的

在本地回归中使用的数据点的比例,指定为逗号分隔对'跨度'和标量值在0到1之间。仅当方法Lowessfit

数据类型:双倍的

线性和非线性最小二乘选项

全部收缩

强大的线性最小二乘拟合方法,指定为逗号分隔对'强大的'这些价值之一:

  • 'lar'指定绝对残留方法。

  • 'Bisquare'指定Bisquare权重法。

Available when the方法线性广场或者nonearleastsquares

数据类型:char

拟合系数的下限,指定为逗号分隔对'降低'和矢量。默认值是一个空的向量,表明拟合不受下限的不受限制。如果指定边界,则矢量长度必须等于系数的数量。通过使用系数功能。例如,请参阅合身。可以通过-inf

Available when the方法线性广场或者nonearleastsquares

数据类型:双倍的

上bounds on the coefficients to be fitted, specified as the comma-separated pair consisting of'上'和矢量。默认值是一个空的向量,表明该拟合不受上限不受限制。如果指定边界,则矢量长度必须等于系数的数量。通过使用系数功能。例如,请参阅合身。可以通过+Inf

Available when the方法线性广场或者nonearleastsquares

数据类型:逻辑

非线性最小二乘选项

全部收缩

系数的初始值,指定为逗号分隔对'起点'和矢量。通过使用系数功能。例如,请参阅合身

如果没有起点(空向量的默认值)将传递给合身功能,某些库模型的起点是通过启发性确定的。对于理性和Weibull模型以及所有自定义非线性模型,工具箱从间隔(0,1)随机随机选择默认的初始值。结果,使用相同数据和模型的多个拟合可能会导致不同的系数。为避免这种情况,请指定具有矢量值的系数的初始值起点财产。

Available when the方法nonearleastsquares

数据类型:双倍的

用于拟合过程的算法,指定为逗号分隔对'算法'和either'Levenberg-Marquardt'或者'Trust-Region'

Available when the方法nonearleastsquares

数据类型:char

有限差梯度系数的最大变化,指定为逗号分隔对“ diffmaxchange'和标量。

Available when the方法nonearleastsquares

数据类型:双倍的

有限差梯度系数的最小变化,指定为逗号分隔对“ diffminchange'和标量。

Available when the方法nonearleastsquares

数据类型:双倍的

在命令窗口中显示选项,指定为逗号分隔对'Display'这些选项之一:

  • '通知'仅当拟合不收敛时显示输出。

  • '最后'仅显示最终输出。

  • 'iTer'在每次迭代处显示输出。

  • 'off'displays no output.

Available when the方法nonearleastsquares

数据类型:char

允许的最大评估数量,指定为逗号分隔对,由“ maxfunevals”和标量。

Available when the方法nonearleastsquares

数据类型:双倍的

拟合允许的最大迭代次数,指定为逗号分隔对'Maxiter'和标量。

Available when the方法nonearleastsquares

数据类型:双倍的

模型值的终止公差,指定为逗号分隔对'Tolfun'和标量。

Available when the方法nonearleastsquares

数据类型:双倍的

系数值的终止公差,指定为逗号分隔对'tolx'和标量。

Available when the方法nonearleastsquares

数据类型:双倍的

输出参数

全部收缩

算法选项,返回为fitoptions目的。

New algorithm options, returned as afitoptions目的。

版本历史记录

在R2006a之前引入