Save old values in an iteration (while loop)
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mehdi
le 7 Sep 2015
Réponse apportée : Walter Roberson
le 8 Sep 2015
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 commentaires
Réponse acceptée
Walter Roberson
le 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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!