c#怎么拟合函数得到参数,具有两个参数的方程的曲线拟合

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?

解决方案

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值