注册地址 登录
数学建模社区-数学中国 返回首页

大智若愚的个人空间 http://www.madio.net/?588208 [收藏] [复制] [分享] [RSS]

日志

Matlab的曲线拟合工具箱CFtool使用

热度 1已有 638 次阅读2013-1-25 15:09 | 工具箱, 曲线

Matlab的曲线拟合工具箱CFtool使用

it 2010-04-06 11:24:00 阅读98 评论0   字号:大中小 订阅

下面结合我使用的 Matlab R2007b 来简单介绍如何使用这个工具箱。

假设我们要拟合的函数形式是 y=A*x*x + B*x, A>0,B>0

1、在命令行输入数据:

x=[110.3323 148.7328 178.064 202.8258033 224.7105 244.5711 262.908 280.0447

296.204 311.5475]

y=[5 10 15 20 25 30 35 40 45 50]

后点击“Create data set”按钮,退出“Data”窗口,返回工具箱界面,这时会自动画出数

选择数据集,然后通过下拉菜单“Type of fit”选择拟合曲线的类型,工具箱提供的拟合类

型有:

Custom Equations:用户自定义的函数类型

Exponential:指数逼近,有2种类型, a*exp(b*x) a*exp(b*x) + c*exp(d*x)

Fourier:傅立叶逼近,有7种类型,基础型是 a0 + a1*cos(x*w) + b1*sin(x*w)

Gaussian:高斯逼近,有8种类型,基础型是 a1*exp(-((x-b1)/c1)^2)

Interpolant:插值逼近,有4种类型,linearnearest neighborcubic splineshape-

preserving

Polynomial:多形式逼近,有9种类型,linear ~quadratic ~cubic ~4-9th degree ~

Power:幂逼近,有2种类型,a*x^b a*x^b + c

Rational:有理数逼近,分子、分母共有的类型是linear ~quadratic ~cubic ~4-5th

degree ~;此外,分子还包括constant

Smoothing Spline:平滑逼近(翻译的不大恰当,不好意思)

Sum of Sin Functions:正弦曲线逼近,有8种类型,基础型是 a1*sin(b1*x + c1)

Weibull:只有一种,a*b*x^(b-1)*exp(-a*x^b)

Equations线性等式“General Equations构造等式两种标签。

在本例中选Custom Equations,点击“New”按钮,选择“General Equations”标签,输入函

数类型y=a*x*x + b*x,设置参数ab的上下限,然后点击OK

5)类型设置完成后,点击“Apply”按钮,就可以在Results框中得到拟合结果,如下例:

Coefficients (with 95% confidence bounds):

a = 0.009194 (0.009019, 0.00937)

b = 1.78e-011 (fixed at bound)

Goodness of fit:

SSE: 6.146

R-square: 0.997

Adjusted R-square: 0.997

RMSE: 0.8263

同时,也会在工具箱窗口中显示拟合曲线。

这样,就完成一次曲线拟合啦,十分方便快捷。当然,如果你觉得拟合效果不好,还可以在

Fitting”窗口点击“New fit”按钮,按照步骤(4~5)进行一次新的拟合。

不过,需要注意的是,cftool 工具箱只能进行单个变量的曲线拟合,即待拟合的公式中,变

量只能有一个。对于混合型的曲线,例如 y = a*x + b/x ,工具箱的拟合效果并不好。下一

篇文章我介绍帮同学做的一个非线性函数的曲线拟合。

以上内容出自:

http://hi.baidu.com/snowlxm/blog/item/15a714b122ae95500823025f.html

上边对cftool工具箱做了很详尽的说明,但并没有对各种曲线拟合的性能做点评,在单变量曲线拟合中,如何选取一种最优化的拟合方式是非常重要的,我们在采用CFTOOL拟合后,会有一些性能说明,如:

Goodness of fit:

SSE: 6.146

R-square: 0.997

Adjusted R-square: 0.997

RMSE: 0.8263

官方的解释:

Results -- Displays detailed results for the current fit including the fit type (model, spline, or interpolant), the fitted coefficients and 95% confidence bounds for parametric fits, and these goodness of fit statistics:

SSE -- The sum of squares due to error. This statistic measures the deviation of the responses from the fitted values of the responses. A value closer to 0 indicates a better fit.

R-square -- The coefficient of multiple determination. This statistic measures how successful the fit is in explaining the variation of the data. A value closer to 1 indicates a better fit.

Adjusted R-square -- The degree of freedom adjusted R-square. A value closer to 1 indicates a better fit. It is generally the best indicator of the fit quality when you add additional coefficients to your model.

RMSE -- The root mean squared error. A value closer to 0 indicates a better fit.


路过

雷人

握手

鲜花

鸡蛋

发表评论 评论 (1 个评论)

回复 等风来的十字狐 2018-1-16 00:57
怎么和网上的一样 。。。

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2025-9-16 12:20 , Processed in 0.251785 second(s), 28 queries .

回顶部