MATLAB Answers

Save old values in an iteration (while loop)

56 views (last 30 days)
Hi,
In Newton_Raphson iteration, I need to compare old and new values of X so that it stops when their difference is very small. How can I save old values? Thank you very much in advance.

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Sep 2015
prev_value = inf;
while true
new_value = .... some calculation
if abs(prev_value - new_value) < YourTolerance
break;
end
prev_value = new_value;
end

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.