フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I'm confused to how this conversion works for a for to while loop

2 ビュー (過去 30 日間)
Zachary Holmes
Zachary Holmes 2015 年 12 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
If the for loop is
for i=2:3:20
disp(i);
end
Would the while loop be:
i=2
while (i<20)
i=i+3
disp(i)
end
  1 件のコメント
Thorsten
Thorsten 2015 年 12 月 2 日
What exactly confuses you?

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 12 月 2 日
編集済み: Walter Roberson 2015 年 12 月 2 日
Your question is much improved from what you posted first.
The answer is "not quite". The while loop you have programmed does not display 2.
You need to do the action of the loop before you increment the loop control variable, and you need to be careful about what to do if the control variable is exactly equal to the final allowed value.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by