How to pause a for loop until the enter key is pressed?
조회 수: 68 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Kirby Fears
2015년 11월 17일
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개)
참고 항목
카테고리
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!