MATLABに基づくガウスニュートンソースコード



Gauss Newton Source Code Based Matlab



ガウスニュートンの原理に精通していない小さなパートナーについては、ブロガーが書いたブログを参照できます。 http://blog.csdn.net/zhubaohua_bupt/article/details/74973347

このお姉さんのおかげで、彼のブログも読んで、とても気持ちがいいです。私のコードもブロガーのブログに基づいているので、コードを見る前にブロガーのブログを見る必要があります。



MATLABのソースコードは次のとおりです。

function [X,Y]=GaussNewton clear clc tic %% Gauss Newton algorithm, X0 is the initial point and e is the iterative error value X0=[00] % initial point e=0.001 % threshold syms x1 x2 F(1)=x1-0.7*sin(x1)-0.2*cos(x2) % objective function value F(2)=x2-0.7*cos(x1)+0.2*sin(x2) A=jacobian(F,[x1,x2]) % finds the Jacobian matrix of the objective function H=A.'*A % ask for A.'*A, which will be used later H=-inv(H) % inverts H and takes the opposite %% for iterative loop for k=1:20 f=double(subs(F,[x1 x2],x0'))' % assigns the initial value of the iteration to the objective function h=double(subs(H,[x1 x2],x0')) % assigns k initial iterations to H a=double(subs(A.',[x1 x2],x0')) % for a, 'given k times iteration initial value x=x0+h*a*f % solves the solution of k iterations, even if the objective function is optimal Delet=sqrt(sum((x-x0).^2)) % error value If delet