Displaying results of lsqcurvefit after each iteration

조회 수: 5 (최근 30일)
Sergio Quesada
Sergio Quesada 2018년 6월 11일
댓글: Sergio Quesada 2018년 6월 12일
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 !!

채택된 답변

Alan Weiss
Alan Weiss 2018년 6월 11일
Write yourself a simple Output Function such as this:
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
  댓글 수: 1
Sergio Quesada
Sergio Quesada 2018년 6월 12일
done! thanks! Time to read more about output functions....

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by