How to pause a for loop until the enter key is pressed?

For example, say I want to print the numbers from 1 to 10. I want it to wait until the enter key is pressed to print the next number.

 採用された回答

Kirby Fears
Kirby Fears 2015 年 11 月 17 日

3 投票

Use the pause command.
for ind = 1:10,
pause;
disp(ind);
end
In the command window, you will need to press any key to continue each time "pause" is reached.
Alternatively, you can use the input command which will be enter-key specific. Just replace pause with input('').

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

Don
2015 年 11 月 17 日

コメント済み:

Don
2015 年 11 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by