Borrar filtros
Borrar filtros

checking if values are equal in a loop

3 visualizaciones (últimos 30 días)
María Jesús
María Jesús el 7 de En. de 2015
Respondida: Guillaume el 7 de En. de 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!

Respuesta aceptada

Guillaume
Guillaume el 7 de En. de 2015
Use a while loop:
lastvalue = Inf;
newvalue = -Inf;
while newvalue ~= lastvalue
lastvalue = newvalue;
newvalue = ... %the result of your calculation
end

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by