How to iterate so it will converge

조회 수: 26 (최근 30일)
A
A 2019년 9월 23일
댓글: Rena Berman 2019년 10월 28일
Hi so im trying to iterate this code so that it will converge, but Im not getting how to do it. I did it manually, but im not able to use any loops cause it wont work out...
Heres how I did it manually... just cant figure out how to soft code it... and the delta values must be> 0.0001. Like I belive is suppose to be like while> delta(i)>0.0001. And also, all variables shown below are vectors.
%Code shown below
end
%First Iteration
l_0=InMeas(Angles,Distance,Coordinate,x_0); %Function
A=Amatrix(Angles,Distance,Coordinate,x_0); %Function
w0=l_0-l; % Also this has to get updated
delta0= -inv(A.'*P*A)*A.'*P*w0
xhat=x_0+delta0; %This needs updating
%2nd Iterations
l_01=InMeas(Angles,Distance,Coordinate,xhat); %Function
A1=Amatrix(Angles,Distance,Coordinate,xhat); %Function
w01=l_01-l; % Also this has to get updated
delta01= -inv(A1.'*P*A1)*A1.'*P*w01
xhat1=xhat+delta01; %This needs updating
  댓글 수: 2
Stephen23
Stephen23 2019년 9월 25일
AB's Original Question (from Google Cache):
Hi so im trying to iterate this code so that it will converge, but Im not getting how to do it. I did it manually, but im not able to use any loops cause it wont work out...
Heres how I did it manually... just cant figure out how to soft code it...
%First Iteration
l_0=InMeas(Angles,Distance,Coordinate,x_0); %Function
A=Amatrix(Angles,Distance,Coordinate,x_0); %Function
w0=l_0-l; % Also this has to get updated
delta0= -inv(A.'*P*A)*A.'*P*w0
xhat=x_0+delta0; %This needs updating
%2nd Iterations
l_01=InMeas(Angles,Distance,Coordinate,xhat); %Function
A1=Amatrix(Angles,Distance,Coordinate,xhat); %Function
w01=l_01-l; % Also this has to get updated
delta01= -inv(A1.'*P*A1)*A1.'*P*w01
xhat1=xhat+delta01; %This needs updating
Rena Berman
Rena Berman 2019년 10월 28일
(Answers Dev) Restored edit

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

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 23일
편집: KALYAN ACHARJYA 2019년 9월 23일
but im not able to use any loops cause it wont work out...
The convergence criteria is not related with loop (its do just repetition),its based mathematical modeling of the problem. As my undestanding, the requiremnt is xhat to be converge (no chage) after certain iterations, when xhat is converge, then loop must be terminated. Hints, you may think this way, but still you have to ensure that after certains times of iterations, xhat must be ramain same (unchanged)
while xhat_present~=xhat_initial
%your code
end
Also requested you to check the @Walter's Answer on while loop convergence criteria
  댓글 수: 3
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 23일
편집: KALYAN ACHARJYA 2019년 9월 23일
Any equations convergent or not depends on maths equation or model. Suppose if you consider any linear equation, such equation will never converged after infinite interartions also.
Have you check your equations manually, after certain iterations, xhat will be converged?
Can you show the Maths details?
A
A 2019년 9월 23일
편집: A 2019년 9월 23일
delta is the one that converges, but unfortunatley the delta value is getting bigger and I iterate it. The math details are the ones shown in the code

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

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by