Problems with lsqnonlin - initial parameters not changing

10 ビュー (過去 30 日間)
E
E 2023 年 4 月 24 日
回答済み: Taiha 2023 年 9 月 22 日
Hello, I am trying to find the kinetic parameters for the production of CO and CO2 by comparing experimental data with the data generated by the model and minimzing the difference. The code itself runs, however, the initial guesses are not changing.
InitGuess=[1.4833e10/60 97000 5.9331e10/60 97000];
objf=@(P)ObjFunE(P, tspan, y0, ExpConc, Tref, n);
options=optimoptions("lsqnonlin","Algorithm","levenberg-marquardt");
lb=[0 0 0 0];
ub=[1e11 1e6 1e11 1e6];
[P,resnorm,residual,exitflag,output,lambda,jacobian]=lsqnonlin(objf,InitGuess,lb,ub,options)
ObjFunE is an ode15s solver that generates the model data and then substract it from the experimental data.
  2 件のコメント
chicken vector
chicken vector 2023 年 4 月 24 日
The initialGuess is not supposed to change.
The converged results are stored in P.
E
E 2023 年 4 月 24 日
hello, I meant that P is not changing. it is keeping the values that i introduced in InitGuess.

サインインしてコメントする。

回答 (2 件)

Alan Weiss
Alan Weiss 2023 年 4 月 24 日
We don't see your ObjFunE code, so cannot be sure of what is going on. It seems that you are solving an ODE to create some output. I do not see where you subtract that output from experimental data. Are you summing and squaring the difference? If so, that is a mistake; you should have ObjFunE return a vector that lsqnonlin implicitly squares and sums.
It is also possible that your ODE has a bit of noise in the solution that stops lsqnonlin from converging. See Optimizing a Simulation or Ordinary Differential Equation.
And it is also possible that your issue is the scale of your response variables. Perhaps you can divide the first and third components by 1e10 and the second and fourth by 1e5, and then unscale them within your function, so that the variables you pass are all of more of less the same order of magnitude.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Taiha
Taiha 2023 年 9 月 22 日
Lsqnonlin (sometimes) does not work well when initial values are largely different, that is, if your two initial vales are a = 0.001 and b = 1000.
For safety, I always use scaling. I set all initial values as 1, and pass proper initial guesses as parameters to the fit-function to correctly calculate diference vector.

カテゴリ

Help Center および File ExchangeEigenvalue Problems についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by