OutputFcn for selfmade function to show iteration steps
이전 댓글 표시
Hello there,
I have written my own Levenberg-Marquardt Algorithm as shown below.
Now I want to show every step of the Iteration. Normally I do this with OutputFcn, but this won't work because OutputFun is only for Matlab functions (so I think).
How can I do this otherwise? Is there another option to integrate an OutputFcn? Otherwise I would need to save every x of the iteration, but I don't know how.
(By the way, there is a mistake in the Algorithm, where if eps_mu <=beta 0 x = x-s is wrong. There should be x(k+1) = x(k) which I also don't know how to do, but I am working on this ;) )
Thanks für every help :)
function x=levenberg_marquardt(f,dF,x0,mu0,beta0,beta1,maxit,tol)
n=length(x0);
k=0;
mu=mu0;
x=x0;
s=-(dF(x0)'*dF(x0) + mu^2*eye(n))\(dF(x0)'*f(x0));
while norm(s)>tol && k<maxit
for k=k+1
s=-(dF(x)'*dF(x)+mu^2*eye(n))\(dF(x)'*f(x));
eps_mu=0.5*((f(x)'*f(x)-(f(x+s)'*f(x+s)))/(-s'*dF(x)'*f(x)));
if eps_mu <= beta0
x=x-s;
mu=mu/2;
else
x=x+s;
if eps_mu >= beta1
mu=2*mu;
end
end
end
end
end
댓글 수: 5
Walter Roberson
2020년 12월 22일
What is it that you want to display at each point of the algorithm, and what form do you want to display it?
Nico Lange
2020년 12월 22일
Nico Lange
2020년 12월 23일
Walter Roberson
2020년 12월 23일
In the time since then, I have had activity on more than 70 Questions. I have been working so much on responding to people the last while that I am very behind in my Christmas preparations..
Nico Lange
2020년 12월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!