Stop a infinite while loop pressing a key in Matlab
问题 I have a while loop, infinite, and I want to stop it when I press a keyboard key. Pseudocode: While(1) do stuff; listening for key; if key is pressed break; end end The function waitforbuttonpress makes me press the key, so no luck. I've found no option on the web. 回答1: I suppose if you don't want to resort to multithreading (one thread doing the computation in the while loop, another one waiting for input and setting a global sentinel value to break the while loop) you can try to implement