1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > matlab cftool origin 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matl

matlab cftool origin 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matl

时间:2020-03-17 16:20:31

相关推荐

matlab cftool origin 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matl

在Origin中使用自定义函数进行非线性拟合

/wuhen211@126/blog/static/747463505233269949/

matlab拟合工具箱cftool

%拟合数据曲线;线性最小二乘法是解决曲线拟合的最常用的方法,

%1、多项式拟合函数;p=polyfit(x,y,n);求p拟合函数在xi处的近似值pi=polyval(p,xi);

%2、利用常用矩阵的除法解决复杂函数的拟合;

%3、利用lsqcurvefit函数和lsqnonlin函数拟合;

%4、利用cftool工具箱,自定义编写函数再通过M文件导出的形式

http://phylab./doku.php?id=howtos:matlab:mt1-5

/zzz700/blog/item/f313a3f5869659b5a40f52d7.html英文参考

一、 单一变量的曲线逼近

Matlab有一个功能强大的曲线拟合工具箱 cftool ,使用方便,能实现多种类型的线性、非线性曲线拟合。下面结合我使用的 Matlab Rb 来简单介绍如何使用这个工具箱。

假设我们要拟合的函数形式是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];2、启动曲线拟合工具箱》cftool3、进入曲线拟合工具箱界面“Curve Fitting tool”(1)点击“Data”按钮,弹出“Data”窗口;(2)利用X data和Y data的下拉菜单读入数据x,y,可修改数据集名“Data set name”,然后点击“Create data set”按钮,退出“Data”窗口,返回工具箱界面,这时会自动画出数据集的曲线图;(3)点击“Fitting”按钮,弹出“Fitting”窗口;(4)点击“New fit”按钮,可修改拟合项目名称“Fit name”,通过“Data set”下拉菜单选择数据集,然后通过下拉菜单“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种类型,linear、nearest neighbor、cubic spline、shape-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)

选择好所需的拟合曲线类型及其子类型,并进行相关设置:——如果是非自定义的类型,根据实际需要点击“Fit options”按钮,设置拟合算法、修改待估计参数的上下限等参数;——如果选Custom Equations,点击“New”按钮,弹出自定义函数等式窗口,有“Linear Equations线性等式”和“General Equations构造等式”两种标签。在本例中选Custom Equations,点击“New”按钮,选择“General Equations”标签,输入函数类型y=a*x*x + b*x,设置参数a、b的上下限,然后点击OK。(5)类型设置完成后,点击“Apply”按钮,就可以在Results框中得到拟合结果,如下例:general model:

f(x) = a*x*x+b*x

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 ,工具箱的拟合效果并不好。下一篇文章我介绍帮同学做的一个非线性函数的曲线拟合。

上边对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.

Matlab曲面拟合和插值 AAAAAAAAAAA风云博客

http://xiaoqiang851224./blog/#m=0&t=1&c=fks_084066080086083064084085083095087086083071083086086064

http://suhao198706./blog/static/6217340321095512602/?fromdm&fromSearch&isFromSearchEngine=yes

Matlab曲线拟合

http://xiaoqiang851224./blog/static/3024700353083539419/?fromdm&fromSearch&isFromSearchEngine=yes

多项式拟合函数polyfit之C语言的源码

http://xiaoqiang851224./blog/static/3024700310251055758/

matlab二元函数拟合;

/question/141374449.html?fr=qrl&cid=93&index=2

matlab非线性拟合1(指数函数)

http://apps./share/detail/43922314

matlab cftool origin 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matlab拟合工具箱cftool...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。