필터 지우기
필터 지우기

checking if values are equal in a loop

조회 수: 1 (최근 30일)
María Jesús
María Jesús 2015년 1월 7일
답변: Guillaume 2015년 1월 7일
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!

채택된 답변

Guillaume
Guillaume 2015년 1월 7일
Use a while loop:
lastvalue = Inf;
newvalue = -Inf;
while newvalue ~= lastvalue
lastvalue = newvalue;
newvalue = ... %the result of your calculation
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by