Save old values in an iteration (while loop)

조회 수: 3 (최근 30일)
Mehdi
Mehdi 2015년 9월 7일
답변: Walter Roberson 2015년 9월 8일
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.

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 8일
prev_value = inf;
while true
new_value = .... some calculation
if abs(prev_value - new_value) < YourTolerance
break;
end
prev_value = new_value;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Newton-Raphson Method에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by