Clear Filters
Clear Filters

How to run loop until user enters text in the command window? (without using the input function)

18 views (last 30 days)
I want a script to run in a loop until the user enters something in the command window, at which point the loop will break and continue with the rest of the script. Perhaps there is a line in the loop where it "looks" at the command window's "buffer?" I don't want to use the input function because I don't want the user to be prompted every time the loop runs.
Brian on 16 Oct 2023
I don't want the script to pause--basically I want the script to run continuously until something is entered in the command window which would lead to breaking the loop.
Seems someone else asked the same question already with no proper answer:

Sign in to comment.

Accepted Answer

Mario Malic
Mario Malic on 17 Oct 2023
Edited: Mario Malic on 17 Oct 2023
Undocumented and subject to change but it works, at least when it was tested back then

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange





Community Treasure Hunt

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

Start Hunting!