Comparing updated array from two consecutive iterations
4 次查看(过去 30 天)
显示 更早的评论
Hi, I need to create a while loop for a for loop which iterates until the difference between the array c of the current iteration and the array c of the previous iteration is small. Any suggestions on how I could save the updated array for each iteration and then compare the 2 consecutive iterations?
0 个评论
采纳的回答
更多回答(1 个)
Roger Stafford
2017-4-17
Use a while loop that is sure to make at least two trips through.
old = all NaNs so as to surely fail 1st test
b = false;
while ~b
new = ...
b = old and new difference is sufficiently small
old = new;
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!