lsqcurvefit answer upon termination?

2 次查看(过去 30 天)
I'm curious about what answer lsqcurvefit is giving me when it terminates. When the program ends due to reaching number of iterations, does the answer (x) come from the last iteration or does it return the best answer based on previous iterations? By best I mean lowest first order optimality measure, step size, function tolerance size, etc.
  2 个评论
Torsten
Torsten 2024-3-11
x and fval come from the last iteration.
Nicholas Ross
Nicholas Ross 2024-3-11
@Torsten thanks for the response. Is there a way to change it to where it sets x and fval based on the lowest output of either first order optimality, step size, or function tolerance? For example if the 45th iteration showed the lowest stepsize, use the values at that iteration to set x

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2024-3-11
编辑:Matt J 2024-3-11
You can use a nested OutputFcn, like in this example,
to save the entire iteration history of x and resnorm values. You can then retrospectively pick the solution that you want from the whole iteration sequence.
You could also modify this example to save only the best-so-far x vector, rather than the whole history.
  5 个评论
Torsten
Torsten 2024-3-11
编辑:Torsten 2024-3-11
The variable "resnorm" in the output from "lsqcurvefit" represents f(x).
Nicholas Ross
Nicholas Ross 2024-3-12
@Torsten thanks for this note. That actually cleared up another question I had.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by