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.

採用された回答

Amit
Amit 2014 年 1 月 29 日
just like for loop, you can use
while true
you code
end
  2 件のコメント
Ahtisham
Ahtisham 2014 年 1 月 29 日
yes but for a FOR loop we have to set a number of times the loop runs but how is it possible with the while loop since it runs infinitely, im sorry if i am missing something i'm new to matlab so if you will be a bit more specific
Amit
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 ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by