checking if values are equal in a loop
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
María Jesús
le 7 Jan 2015
Réponse apportée : Guillaume
le 7 Jan 2015
Hi,
I have a program that estimates some parameters iteratively and returns the value after a set number of iterations of a for loop. Is there a way to get the loop to go on only until the result of two iterations are the same?
Thank you!
0 commentaires
Réponse acceptée
Guillaume
le 7 Jan 2015
Use a while loop:
lastvalue = Inf;
newvalue = -Inf;
while newvalue ~= lastvalue
lastvalue = newvalue;
newvalue = ... %the result of your calculation
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Quadratic Programming and Cone Programming dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!