Displaying results of lsqcurvefit after each iteration
5 views (last 30 days)
Show older comments
Sergio Quesada
on 11 Jun 2018
Commented: Sergio Quesada
on 12 Jun 2018
Good evening,
I have solved a problem with lsqcurvefit, and now I want MatLab to display the solutions found after each iteration. The problem is my objective function, called "Iteor", is obtained by fsolve, like this:
rteor=@(k,r) fsolve(@(r) arrayfun(@(R,T) FC.*integral(@(x) exp(-a./(x.*log(x))), 1, R)-(T-(.001.*k(1))),r,texp), inpts, options);
Iteor=@(k,r) ((.01.*k(2)./FC).*(rteor(k,texp)).*exp(a./(rteor(k,texp)).*log(rteor(k,texp))))+(Vo./(100.*k(3).*log(rteor(k,texp))));
k = lsqcurvefit(Iteor, x0, texp, Iexp,[],[],options)
I have tried with
options = optimoptions('lsqcurvefit','Display','iter');
but, it returns technical info, not the solutions of my parameters. I've also tried with
options = optimoptions('lsqcurvefit','PlotFcn','optimplotx');
,but it makes the program to plot the parameters values in a graph, and I want it displayed...
Thanks you !!
0 Comments
Accepted Answer
Alan Weiss
on 11 Jun 2018
function stop = outfun(x,optimVals,state)
stop = false;
switch state
case 'iter'
disp(x)
end
I just wrote this off the top of my head, so it might not be 100% right, but something like this will work. Include the output function in your options, and pass the options to lsqcurvefit.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!