I am trying to exit a for loop using toggle button, created using guide. Toggle button is initially called 'Run'. The iteration starts when 'Run' is hit and the toggle button string changes to 'Stop'. However, iteration continues after 'Stop' is hit (in the screenshot, 'Stop' is hit at i=2). I used dbstack to check the Run callbacks. Am I missing something obvious?? Any help would be appreciated. Here's the code snippet and the command window screenshot-
MATLAB: Toggle button to stop a for loop not working
matlab gui toggle button start/stop
Best Answer