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일

0 개 추천

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

Nicholas Ross
Nicholas Ross 2024년 3월 11일
Thanks @Matt J. I'm playing around with this now to see if I can get this to work. Regarding the output, there's 'f(x)', norm of step, first-order optimality, etc. My understanding is that 'f(x)' is the model prediction, 'norm of step' is the current step size at that iteration, and 'first order optimality' tells you if you're heading in the right direction at that iteration. Which is the better metric to look at when determining which is the best stopping point (when f(x), step size, function tolerancee, or optimality is smallest)? Or does each iteration have the best guess each time?
Torsten
Torsten 2024년 3월 11일
편집: Torsten 2024년 3월 11일
The "best" iteration is of course the one where f(x) is minimum (assuming possible constraints on x are satisfied).
Nicholas Ross
Nicholas Ross 2024년 3월 11일
Thanks for clarifying this. It seems obvious enough but being new to this area I wasn't quite sure if I was missing something.
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개)

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2024년 3월 11일

댓글:

2024년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by