error a>b = true when a=b

in a cycle while a>b. when i get a=b inside the cycle the program doesn't stop.. if i do while a<b doesn't stop too.. if i print the number they are equal(eg 0.005). can be an approximation problem?
k=2;
while (f(x_old,y_old)<f(aux_x,aux_y))
aux_x = x_old - (1/k)*step_x;
aux_y = y_old - (1/k)*step_y;
k=k+1;
end

댓글 수: 1

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 9일
편집: Azzi Abdelmalek 2013년 2월 9일
What do you want exactly?

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

 채택된 답변

Jan
Jan 2013년 2월 9일

0 개 추천

Remember, that 0.005 and 0.0049999999999999 are displayed equally in the command window, but they are not exactly equal. Check this by a subtraction:
format short
a = 0.00499999999999
% >> 0.0050
a - 0.005
% >> -9.9998e-015

댓글 수: 1

Marco Vaz
Marco Vaz 2013년 2월 13일
yes, it is an approximation error.. thanks

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

질문:

2013년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by