필터 지우기
필터 지우기

I wanna end iteration when result cannot be changed anymore.

조회 수: 1 (최근 30일)
sermet
sermet 2013년 6월 13일
for example
latitude=atan((Z/P)*(1-(e1*N/(N+h)))^-1)*180/pi
N=((a^2/sqrt((a^2*cos(latitude*pi/180)^2+b^2*sin(latitude*pi/180)^2))))
h=(P/(cos(latitude*pi/180))-N)
latitude_i=atan((Z/P)*(1-(e1*N/(N+h)))^-1)*180/pi
dx=latitude_i-latitude
while dx~=0
%this difference will never be zero but very close to zero. I wanna end iteration when iteration cannot change dx anymore.
do again the above equations
end

채택된 답변

David Sanchez
David Sanchez 2013년 6월 13일
dx = 5; % set initial value here
% my_threshold = eps; % Floating-point relative accuracy
my_threshold = 0.01; % or whatever value you choose
while dx < my_threshold
latitude=atan((Z/P)*(1-(e1*N/(N+h)))^-1)*180/pi
N=((a^2/sqrt((a^2*cos(latitude*pi/180)^2+b^2*sin(latitude*pi/180)^2))))
h=(P/(cos(latitude*pi/180))-N)
latitude_i=atan((Z/P)*(1-(e1*N/(N+h)))^-1)*180/pi
dx=latitude_i-latitude
end
  댓글 수: 2
sermet
sermet 2013년 6월 13일
I'm working very small numbers like 1.0e-13 also this is not the answer I want.
Bjorn Gustavsson
Bjorn Gustavsson 2013년 6월 13일
0.01 and eps should bracket your 1e-13 nicely. Choose the threshold according to your requirements. You could also extend the number of iterations to do a few between your calculations of dx.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by