criteria to use a while-loop
4 次查看(过去 30 天)
显示 更早的评论
I want to compare the difference between a for-loop and a while-loop.
What are criteria to use a while-loop?
0 个评论
回答(2 个)
madhan ravi
2020-6-11
编辑:madhan ravi
2020-6-11
"What are criteria to use a while-loop?"
If you don't know when the condition is satisfied.
0 个评论
the cyclist
2020-6-11
As a general rule, you will use a for loop when you know ahead of time how many iterations you want, and a while loop when you don't, but instead base the number of iterations on some condition that will get triggered during the loop itself.
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!