MATLAB中的曲线拟合:工具箱与命令行的结果表不同吗? [英] Curve fitting in MATLAB: different result form toolbox vs command line?

查看:158
本文介绍了MATLAB中的曲线拟合:工具箱与命令行的结果表不同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用于Y数据的数据:

This is the data I am using for Y data:

0.577032413537833
0.288198874369377
0.192282280031568
0.143824619265244
0.114952782524097
0.0960518606520442
0.0824041879978560
0.0719078360110914
0.0640919744028295
0.0572120310249072
0.0519630635470660
0.0479380073164273
0.0443712721513307

X只是1到13之间的整数值,我知道这是形式a * x ^ b + c的幂函数,这是通过在MATLAB上以非常高的R平方值(1)运行GUI cftool来实现的.

X is simply the integer value from 1 to 13 and I know that this is power function of form a*x^b+c from running GUI cftool on MATLAB with rather high R-square value (1)

要在命令行上执行拟合,我使用了:

To perform the fit on command line, I used:

>> g = fittype('a*x^b+c','coeff',{'a','b','c'})
>> x=1:13;
>> [c3,gof3] = fit(x',B3(:,1),g)

这将导致

c3 =

 General model:
   c3(x) = a*x^b+c
 Coefficients (with 95% confidence bounds):
   a =        -179  (-1.151e+005, 1.148e+005)
   b =    0.001066  (-0.6825, 0.6847)
   c =       179.5  (-1.148e+005, 1.151e+005)

gof3 =

       sse: 0.0354
   rsquare: 0.8660
       dfe: 10
adjrsquare: 0.8392
      rmse: 0.0595

General model Power2:
       f(x) = a*x^b+c
Coefficients (with 95% confidence bounds):
   a =      0.5771  (0.5765, 0.5777)
   b =      -1.001  (-1.004, -0.9983)
   c = -8.972e-005  (-0.0005845, 0.000405)

Goodness of fit:
  SSE: 4.089e-007
  R-square: 1
  Adjusted R-square: 1
  RMSE: 0.0002022

在cftool GUI界面上运行回归时得到的结果.我在这里缺少哪些选择,这使我在看似模型上的结果大相径庭? a = -179非常可恶....

That I get when I run the regression on cftool GUI interface. What options I am missing here that gives me rather different results on seemingly the model? That a = -179 is very fishy....

谢谢您的输入.

哦,一旦我解决了这些问题,是否有办法从拟合模型中仅获得特定值?说,我只对A的值感兴趣.

Oh also, once I sort those out, is there way to get only particular value from fitted model? Say, I am only interested in values of A.

对于gof,我知道我可以使用gof.rsquare ...提取出来,等等,但是对于cfit呢?

for gof, I know I can extract out by using gof.rsquare... and so on, but how about for cfit?

推荐答案

当我尝试做

>> g = fittype('a*x^b+c','coeff',{'a','b','c'})
>> x=1:13;
>> [c3,gof3] = fit(x',B3(:,1),g)

我知道了

Warning: Start point not provided, choosing random start point. 
> In Warning>Warning.throw at 31
  In fit>iFit at 320
  In fit at 109 

所以我将其更改为

>> [c3,gof3] = fit(x', B3(:,1),g, 'Startpoint', [0 0 0])

这给了我

c3 = 

     General model:
     c3(x) = a*x^b+c
     Coefficients (with 95% confidence bounds):
       a =      0.5771  (0.5765, 0.5777)
       b =      -1.001  (-1.004, -0.9983)
       c =  -8.972e-05  (-0.0005844, 0.000405)

确实与从cftool GUI获得的非常接近.

which is indeed a lot closer to the one you got from the cftool GUI.

对于GUI而言,随机起始点"可能比对CLI适应要好得多,因此您很幸运.

Quite possibly the "random start point" was a lot better for the GUI than it was for the CLI fit, so you were just lucky.

如果可以始终如一地产生这些结果,那么必须对GUI进行编程,使其在可用时或使用类似方案时也使用全局优化"工具箱.但这只是疯狂的猜测.

If these results can be produced consistently, well, then the GUI must be programmed to also use the Global optimization toolbox when available, or some similar scheme. But that's just wild speculation.

这篇关于MATLAB中的曲线拟合:工具箱与命令行的结果表不同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆