问题描述
我有两个数组:
E= [6656400;
13322500;
19980900;
26625600;
33292900;
39942400;
46648900;
53290000]
和
J=[0.0000000021;
0.0000000047;
0.0000000128;
0.0000000201;
0.0000000659;
0.0000000748;
0.0000001143;
0.0000001397]
我想通过应用以下等式为上述数据找到合适的曲线拟合:
I want to find the appropriate curve fitting for the above data by applying this equation:
J=A0.*(298).^2.*exp(-(W-((((1.6e-19)^3)/(4*pi*2.3*8.854e-12))^0.5).*E.^0.5)./((1.38e-23).*298))
我想从1e-19中选择W的起始值
I want to select the starting value of W from 1e-19
我已经尝试过曲线拟合工具,但是并不能帮助我解决问题!
I have tried the curve fitting tools but it is not helping me to solve it!
然后,我选择了一些随机值A0 = 1.2e9和W = 2.243e-19,这给了我更好的结果.但是我想通过使用代码(而不是曲线拟合应用程序)找到正确的值
Then, I selected some random values of A0=1.2e9 and W=2.243e-19, it gave me a better results. But I want to find the right values by using the code (not the curve fitting Apps)
你能帮我吗?
推荐答案
一种快速(且可能很简单)的解决方法是将曲线拟合作为最小化问题.
A quick (and potentially easy) solution method would be to pose the curve fit as a minimization problem.
定义一个以fit参数作为参数的相关函数:
Define a correlation function that takes the fit parameters as an argument:
% x(1) == A0; x(2) == W
Jfunc = @(x) x(1).*(298).^2.*exp(-(x(2)-((((1.6e-19)^3)/(4*pi*2.3*8.854e-12))^0.5).*E.^0.5)./((1.38e-23).*298));
然后将目标函数最小化.由于您有数据J
,因此我们将数据和相关性之间的差异的平方和最小化:
Then a objective function to minimize. Since you have data J
we'll minimize the sum-of-squares of the difference between the data and the correlation:
Objective = @(x) sum((Jfunc(x) - J).^2);
,然后尝试使用 fminsearch
最小化目标:
And then attempt to minimize the objective using fminsearch
:
x0 = [1.2E9;2.243E-19];
sol = fminsearch(Objective,x0);
我用了你的猜测.对于非线性解决方案,良好的初步猜测通常对于收敛至关重要.
I used the guesses you gave. For nonlinear solutions, a good first guess is often important for convergence.
如果您有优化工具箱,也可以尝试 lsqcurvefit
或 lsqnonlin
(fminsearch
是香草MATLAB).
If you have the Optimization Toolbox, you can also try lsqcurvefit
or lsqnonlin
(fminsearch
is vanilla MATLAB).
这篇关于具有两个参数的方程的曲线拟合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!