Curve Fitting for equation with two parameters

不打扰是莪最后的温柔 提交于 2019-12-12 01:46:36

问题


I have two arrays:

E= [6656400;
    13322500;
    19980900;
    26625600;
    33292900;
    39942400;
    46648900;
    53290000]

and

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))

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!

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)

Can you help me please?


回答1:


A quick (and potentially easy) solution method would be to pose the curve fit as a minimization problem.

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));

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);

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.

If you have the Optimization Toolbox, you can also try lsqcurvefit or lsqnonlin (fminsearch is vanilla MATLAB).



来源:https://stackoverflow.com/questions/28221803/curve-fitting-for-equation-with-two-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!