2017-09-23 43 views
0

我有一些严重问题拟合指数函数(比尔 - 朗伯定律)到我的数据。我使用的优化工具集功能产生可怕千篇一律:符合指数函数的问题

enter image description here

function [ Coefficients ] = fitting_new(Modified_Spectrum_Data,trajectory ) 

x_axis = trajectory; 
fun = @(x,x_axis) (x(1)*exp((-x(2))*x_axis)); 
start = [Modified_Spectrum_Data(1) 0.05]; 

nlm = nlinfit(x_axis,Modified_Spectrum_Data,fun,start,opts); 

Coefficients = nlm; 
end 

数据:

Modified_Spectrum_Data = [1.11111111111111, 1.08784976353957, 1.06352170731165, 1.04099672033640, 1.02649723285838, 1.00423806910703, 0.994116452961827, 0.975928861361604, 0.963081773802984, 0.953191520906905, 0.940636278551651, 0.930360007604054, 0.922259178548511, 0.916659345499171, 0.909149956799775, 0.901241601559703, 0.895375741449218, 0.893308346234150, 0.887985459843162, 0.884657500398024, 0.883852990694089, 0.877158499678129, 0.874817832833850, 0.875428444059047, 0.873170360623947, 0.871461252768665, 0.867913776631497, 0.866459074988087, 0.863819528471106, 0.863228815347816 ,0.864369045426273 ,0.860602502500599, 0.862653463581049, 0.861169231463016, 0.858658616425390, 0.864588421841755, 0.858668693409622, 0.857993365648639] 

trajectory = [0.0043, 0.9996, 2.0007, 2.9994, 3.9996, 4.9994, 5.9981, 6.9978, 7.9997, 8.9992, 10.0007, 10.9993, 11.9994, 12.9992, 14.0001, 14.9968, 15.9972, 16.9996, 17.9996, 18.999, 19.9992, 20.9996, 21.9994, 23.0003, 23.9992, 24.999, 25.9987, 26.9986, 27.999, 28.9991, 29.999, 30.9987, 31.9976, 32.9979, 33.9983, 34.9988, 35.999, 36.9991] 

我已经使用多个不同的拟合函数,并与选项乱搞尝试,但他们似乎没有太大的区别。另外,我尝试改变最初的猜测,但是这再次没有什么区别。

Excel似乎能够很好地适合数据,但我有900行数据我想要适合,所以在Excel中这样做是不可能的。

任何帮助将不胜感激,谢谢。

回答

1

你会想要使用cftool。您的数据看起来遵循权力法律。然后选择'Modified Spectrum Data'作为你的x轴,'Trajectory'选择你的y。从GUI下方的下拉菜单中选择“Power”。

Modified_Spectrum_Data = [1.11111111111111, 1.08784976353957, 1.06352170731165, 1.04099672033640, 1.02649723285838, 1.00423806910703, 0.994116452961827, 0.975928861361604, 0.963081773802984, 0.953191520906905, 0.940636278551651, 0.930360007604054, 0.922259178548511, 0.916659345499171, 0.909149956799775, 0.901241601559703, 0.895375741449218, 0.893308346234150, 0.887985459843162, 0.884657500398024, 0.883852990694089, 0.877158499678129, 0.874817832833850, 0.875428444059047, 0.873170360623947, 0.871461252768665, 0.867913776631497, 0.866459074988087, 0.863819528471106, 0.863228815347816 ,0.864369045426273 ,0.860602502500599, 0.862653463581049, 0.861169231463016, 0.858658616425390, 0.864588421841755, 0.858668693409622, 0.857993365648639] 

trajectory = [0.0043, 0.9996, 2.0007, 2.9994, 3.9996, 4.9994, 5.9981, 6.9978, 7.9997, 8.9992, 10.0007, 10.9993, 11.9994, 12.9992, 14.0001, 14.9968, 15.9972, 16.9996, 17.9996, 18.999, 19.9992, 20.9996, 21.9994, 23.0003, 23.9992, 24.999, 25.9987, 26.9986, 27.999, 28.9991, 29.999, 30.9987, 31.9976, 32.9979, 33.9983, 34.9988, 35.999, 36.9991] 

cftool 

截图:enter image description here

有关曲线拟合(cftool)的更多信息,请参阅:在安装https://www.mathworks.com/help/curvefit/curvefitting-app.html

+0

我见过的改进加上了偏移项,这里将使方程* x^b +偏移。如果这对您的具体情况有意义,请考虑尝试。 –