I need to set up a while loop to compute the projectile’s range for gradually increasing velocities, starting at zero and increasing by 0.1m/s each time. But i have only studied FOR loops and i dont know how to do WHILE loops can someone help ?
1 次查看(过去 30 天)
显示 更早的评论
Set up a while loop to compute the projectile’s range for gradually increasing velocities, starting at zero and increasing by 0.1m/s each time. I could have had done it with for loops but i need to set up a loop for infinite iterations.
0 个评论
采纳的回答
Amit
2014-1-29
just like for loop, you can use
while true
you code
end
2 个评论
Amit
2014-1-29
With while loop you do:
while condition
_Blah_
end
The condition (like x < 1) returns a logical value (true or false, 0 or 1). While will run until that logical value is true. That is why "while true" will run infinitely.
更多回答(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!