button unresponsive while running loop

I have a button that toggles the state of a rogue variable which will terminate a while loop. However, if the while loop is running, the button is unresponsive, and I cannot break the loop without using "ctrl + C".

Answers (1)

Hi Rohit,
You can use 'drawnow' or one of its functional equivalents, such as 'pause(0)' inside of the while loop when it is running and button is unresponsive.
Adding this allows the system to register that the variable has updated, which subsequently breaks the loop.
Please refer the following documentation for drawnow function: https://www.mathworks.com/help/matlab/ref/drawnow.html

Categories

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

Products

Release

R2022b

Tags

Asked:

on 6 Nov 2024

Answered:

on 6 Nov 2024

Community Treasure Hunt

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

Start Hunting!