How to show every iteration step of lsqnonlin()?
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello again,
I am solving a nonlinear compensation problem on a cirlce. So first i am creating 10 points randomly.
phi1=1:((2*pi/10.71)):2*pi;
r = -0.5 + (0.5 + 0.5) * rand(1,10);
xrand = sin(phi1) + 0.25 * r;
yrand = cos(phi1) + 0.25 * r;
figure (1)
sz = 80;
scatter(xrand,yrand,sz,'ob','linewidth',1);
axis ([-1.5 1.5 -1.5 1.5]);
grid on;
hold on
After that, I am using lsqnonlin to solve the equation for a circle and plot the result with the 10 points.
f=@(x)((xrand-x(1)).^2+(yrand-x(2)).^2-x(3).^2)';
x0=[0,0,1];
KreisFit1 = lsqnonlin(f,x0);
figure (1)
phi = linspace(0,2*pi,100);
xFit1 = KreisFit1(3)*cos(phi) + KreisFit1(1);
yFit1 = KreisFit1(3)*sin(phi) + KreisFit1(2);
plot(xFit1,yFit1,'b-','linewidth',3)
hold off
I also want to show every step of the iteration done by lsqnonlin in the same figure.
How can i visualize each Step of the iteration?
Thanks for every help :)
0 comentarios
Respuestas (1)
Steven Lord
el 3 de Dic. de 2020
You probably want to specify a PlotFcn as part of the options that get passed into lsqnonlin. See this documentation page for more information.
3 comentarios
Steven Lord
el 3 de Dic. de 2020
options = optimoptions(@lsqnonlin,'Display','iter-detailed','MaxfunEvals',35);
You did not specify that you wanted lsqnonlin to use a PlotFcn. Consider something along the lines of the attached.
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!