Fsolve with different combinations of parameters
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a system of 11 nonlinear equations and 11 unknown variables that I would like to solve for. The nonlinear equations also depend on a set of parameters. Using the fsolve function, I keep getting the message:
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 8.000000e+03.
I therefore want to nest the fsolve function inside a set of loops over different combinations of parameter values to see if I can get a solution with a different set of parameters. What is the generic code for doing so?
Thank you very much!
0 commentaires
Réponse acceptée
Torsten
le 23 Mai 2023
Modifié(e) : Torsten
le 23 Mai 2023
Varying the initial values for the unknown variables should be the first step. Try "MultiStart".
Varying parameters is usually done via nested for-loops where each loop runs over the values of one of the parameters.
6 commentaires
Torsten
le 24 Mai 2023
Modifié(e) : Torsten
le 24 Mai 2023
Since z is a solution vector with more than one element, you will have to use
z(:,ip1,ip2) = fsolve(@(x)FUNS(x,parameter),zg);
instead of
z(ip1,ip2) = fsolve(@(x)FUNS(x,parameter),zg);
If you still get the error message
Failure in initial objective function evaluation. FSOLVE cannot continue.
try to evaluate your function with the initial values zg before calling "fsolve":
FUNS(zg,parameter)
Plus de réponses (1)
Walter Roberson
le 23 Mai 2023
Increase the maximum evaluations instead.
opts = optimoptions(@fsolve, 'MaxFunctionEvaluations', 1e5, 'MaxIterations', 1e5);
[bestx, fval, exitflag] = fsolve(HANDLE, x0, opts)
0 commentaires
Voir également
Catégories
En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!