lsqcurvefit.m ... how to find intermediate steps?

Hi
I'm fitting using lsqcurvefit and the OUTPUT structure tells me there are 4 steps with 20 function evaluations before the stopping criteria is reached. Is there any way to find the parameter values at each of these steps?
My goal is to plot each fit to demonstrate the improvement between model and data.
Regards, Michael

1 Comment

I'm trying to do this using output functions, but the form of the function seems very restrictive, and it doesn't allow me to store the intermediate values in some pre-allocated matrix. All I can do is print the output, which means everything from that point on must be done manually... any help?

Sign in to comment.

Answers (2)

You could have your objective function print to a text file explicitly or keep a persistent variable around that stores the intermediate steps.

4 Comments

Matt J
Matt J on 31 Oct 2012
Edited: Matt J on 31 Oct 2012
I don't think either solution will work well unless you want to save the result of every single call to your objective function, because it's only through the workspace of the objective function that you would have access to the output.
If you only want the results of a complete iteration, or certain key points of the algorithm, you're better off using OutputFcn.
@Matt: Isn't that what he wants?
Matt J
Matt J on 31 Oct 2012
Edited: Matt J on 31 Oct 2012
His post says that there are 4 "steps" (I assume that means iterations) and 20 function evaluations, and that he wants the parameter values at each of the "steps", not at each function evaluation.
Ahh.. quite possibly, yeah.

Sign in to comment.

Matt J
Matt J on 31 Oct 2012
Edited: Matt J on 31 Oct 2012
No, it's not true that you can't store intermediate output to a matrix using an OutputFcn. The following example shows how to do this

Categories

Asked:

on 31 Oct 2012

Community Treasure Hunt

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

Start Hunting!