fitoptions
创建或修改拟合选项对象
句法
描述
创建默认拟合选项对象fitoptions
= fitoptionsfitoptions
。
为库模型创建默认拟合选项对象。fitoptions
= fitoptions(LibraryModelName
)
为指定库模型创建适合选项,并使用一个或多个指定的其他选项fitoptions
= fitoptions(LibraryModelName
,,,,名称,价值
)名称,价值
pair arguments.
获取指定的拟合选项对象fitoptions
= fitoptions(合身Type
)合身Type
。使用此语法来适用于自定义模型的合适选项。
使用一个或多个指定的其他选项创建适合选项fitoptions
= fitoptions(名称,价值
)名称,价值
pair arguments.
例子
修改默认拟合选项以归一化数据
创建默认拟合选项对象,并在拟合前设置选项以中心和扩展数据。
选项= 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]
Create Fit Options for Linear Least Squares
选项= FitOptions('方法',,,,“线性阵线”)
选项=归一化:'OFF'排除:[]权重:[]方法:'linearleastsquares'ronust:'off''''''':[1x0 double] upper:[1x0 double]
Use Identical Fit Options in Multiple Fits
当您要设置默认拟合选项对象是有用的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)
该算法有困难,如多个系数的宽敞置信区间所示。
为了帮助算法,为非负振幅指定下限a1
和a2
和宽度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)
这是一个更好的选择。您可以通过将合理的值分配给拟合选项对象中的其他属性来进一步改善拟合。
复制和结合拟合选择
创建拟合选项并设置下限。
选项= 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
Change Custom Model Fit Options
创建线性模型拟合类型。
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.normorize ='上'
fo =归一化:'on'ublede:[]权重:[]方法:'linearleastsquares'rounst:'off'''''''':[1x0 double] upper:[1x0 double]
输入参数
LibraryModelName
-适合图书馆模型
角色向量|字符串标量
适合的库模型,指定为字符向量或字符串标量。该表显示了一些常见的示例。
库模型名称 |
描述 |
---|---|
|
线性多项式曲线 |
|
线性多项式表面 |
|
二次多项式曲线 |
|
分段线性插值 |
|
Piecewise cubic interpolation |
|
平滑样条(曲线) |
|
局部线性回归(表面) |
有关库名称列表,请参见模型名称和方程式。
Example:'poly2'
数据类型:char
|细绳
合身Type
-Model type to fit
Fittype
适合的模型类型,指定为Fittype
用Fittype
功能。使用此功能与自定义模型的合适选项一起使用。
fitoptions
-算法选项
fitoptions
算法选项,指定为fitoptions
使用fitoptions
功能。
选项1
-组合算法选项
fitoptions
组合算法选项,,,,constructed using thefitoptions
功能。
选项2
-组合算法选项
fitoptions
组合算法选项,,,,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.
Normalize
-居中和扩展数据的选项
'off'
(默认)|'上'
选项中心和扩展数据,该数据指定为逗号分隔对“正常化”
和'上'
或者'off'
。
数据类型:char
权重
-体重适合
[](默认)|向量
权重为了the fit, specified as the comma-separated pair consisting of“重量”
矢量与数据点数量相同。
数据类型:双倍的
方法
-Fitting method
'没有任何'
(默认)|'最近的人
|“线性插值”
|'PchipInterpolant'
|Cuticspline Interpolant'
|...
拟合方法,指定为逗号分隔对,由'方法'
和one of the fitting methods in this table.
拟合方法 |
描述 |
---|---|
|
最近的邻居插值 |
|
线性插值 |
|
分段立方赫米特插值(仅曲线) |
|
立方样条插值 |
|
Biharmonic surface interpolation |
|
平滑样条 |
|
降低平滑(仅表面) |
|
线性最小二乘 |
|
Nonlinear least squares |
数据类型:char
|细绳
SmoothingParam
-平滑参数
标量值(0,1)
平滑参数,,,,specified as the comma-separated pair consisting of“平滑帕拉姆”
和0到1之间的标量值。默认值取决于数据集。仅当方法
是平滑图
。
数据类型:双倍的
跨度
-在本地回归中使用的数据点的比例
0.25(默认)|标量值(0,1)
在本地回归中使用的数据点的比例,指定为逗号分隔对'跨度'
和标量值在0到1之间。仅当方法
是Lowessfit
。
数据类型:双倍的
Robust
-强大的线性最小二乘拟合法
'off'
(默认)|'lar'
|'Bisquare'
强大的线性最小二乘拟合方法,指定为逗号分隔对'强大的'
这些价值之一:
'lar'
指定绝对残留方法。'Bisquare'
指定Bisquare权重法。
Available when the方法
是线性广场
或者nonearleastsquares
。
数据类型:char
算法
-用于安装过程的算法
'Levenberg-Marquardt'(默认)|'Trust-Region'
用于拟合过程的算法,指定为逗号分隔对'算法'
和either'Levenberg-Marquardt'
或者'Trust-Region'
。
Available when the方法
是nonearleastsquares
。
数据类型:char
DiffMaxChange
-Maximum change in coefficients for finite difference gradients
0.1
(默认)
有限差梯度系数的最大变化,指定为逗号分隔对“ diffmaxchange'
和标量。
Available when the方法
是nonearleastsquares
。
数据类型:双倍的
DiffMinChange
-有限差梯度系数的最小变化
10–8
(默认)
有限差梯度系数的最小变化,指定为逗号分隔对“ diffminchange'
和标量。
Available when the方法
是nonearleastsquares
。
数据类型:双倍的
展示
-在命令窗口中显示选项
'通知'
(默认)|'最后'
|'iTer'
|'off'
在命令窗口中显示选项,指定为逗号分隔对'Display'
这些选项之一:
'通知'
仅当拟合不收敛时显示输出。'最后'
仅显示最终输出。'iTer'
在每次迭代处显示输出。'off'
displays no output.
Available when the方法
是nonearleastsquares
。
数据类型:char
maxfunevals
-允许的最大评估数量
600
(默认)
允许的最大评估数量,指定为逗号分隔对,由“ maxfunevals”
和标量。
Available when the方法
是nonearleastsquares
。
数据类型:双倍的
MaxIter
-Maximum number of iterations allowed for fit
400
(默认)
拟合允许的最大迭代次数,指定为逗号分隔对'Maxiter'
和标量。
Available when the方法
是nonearleastsquares
。
数据类型:双倍的
托尔福
-模型价值的终止公差
10–6
(默认)
模型值的终止公差,指定为逗号分隔对'Tolfun'
和标量。
Available when the方法
是nonearleastsquares
。
数据类型:双倍的
TOLX
-Termination tolerance on coefficient values
10–6。(默认)
系数值的终止公差,指定为逗号分隔对'tolx'
和标量。
Available when the方法
是nonearleastsquares
。
数据类型:双倍的
输出参数
fitoptions
-算法选项
fitoptions
算法选项,返回为fitoptions
目的。
纽约
- 新算法选项
fitoptions
New algorithm options, returned as afitoptions
目的。
版本历史记录
matlab命令
您单击了与此MATLAB命令相对应的链接:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
您还可以从以下列表中选择一个网站:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
美洲
- América Latina(Español)
- 加拿大(英语)
- 美国(英语)