How to show every iteration step of lsqnonlin()?
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Steven Lord
2020 年 12 月 3 日
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 件のコメント
Steven Lord
2020 年 12 月 3 日
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.
参考
カテゴリ
Help Center および File Exchange で Bar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!