Is it possible to update solution-dependent parameters passed as constants in the objective function handle?
For a square system of nonlinear equations, where
- fun(x,a,b,c) is the objective function;
- x is the problem variable, which needs to be guessed by the solver;
- a = ƒ(x), is one of the objective function input variables, x-dependent;
The code for solving the problem, if a wasn't x-dependent, would be:
x = fsolve(@(x) fun(x,a,b,c),x0,options);
But this fixes the value for a at the moment of the creation of the anonymous function handle, while it should be computed inside fun to be updated in each solver iteration.
Is it possible to get a as an output from fun and pass it to fun itself in the next fsolve iteration?
Best Answer