How to use fsolve to optimize and minimize given parameters
2 views (last 30 days)
Show older comments
As part of an algorithm I am implementing (described here), I need to use MATLAB's fsolve function to solve the following:
Where fsolve must iterate t1, t2, tf, and the L2 norms of L, (1)H, and (2)H are provided by my inner loop embedded function (too complex to discuss in one question).
Currently I am implementing it as follows:
%% Call and solve inner loop using provided time parameters
fun = @(x) TFC_InnerLoop_PD(x, otherParameters);
x0 = [t1 t2 tf];
x = fsolve(fun, x0);
However, every time it ends with message "fsolve stopped because the relative size of the current step is less than the value of the step size tolerance and the vector of function values is near zero as measured by the value of the function tolerance." The vector returned by x is always exactly the same as my initial t1, t2, tf guess parameters. Have I misunderstood fsolve, or is the problem likely within my inner loop?
Many thanks.
0 Comments
Accepted Answer
Matt J
on 14 Feb 2022
Edited: Matt J
on 14 Feb 2022
Whether the final point is the same as the initial point or not, the message is telling you that the final point does solve the equations. You can verify whether that's true by looking at the fval output,
[x,fval,exitflag] = fsolve(fun, x0);
or just by evaluating fun(x) yourself.
Since you obviously don't expect the initial point to be a solution, there probably is an issue in the equation funciton that you've provided.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!