Why is Ctrl-C inconsistent in breaking out of loops in MATLAB 7.0 (R14)?

1 次查看(过去 30 天)
I have a MATLAB file function or script that executes a loop many times. When debugging the application, I occasionally need to stop execution before it completes all the iterations of the loop. In MATLAB 6.5 (R13) and earlier versions, Ctrl-C consistently stopped execution of MATLAB functions. In MATLAB 7.0 (R14), Ctrl-C seems to work less frequently.

采纳的回答

MathWorks Support Team
Pressing Ctrl-C while MATLAB is performing a computation adds to a pending event queue. This queue is not necessarily processed during each iteration of a loop, which leads to the behavior where Ctrl-C does not appear to affect program execution. Insert DRAWNOW in the loop to force MATLAB to process the event queue at each iteration of the loop, even if your program does not generate any figures. This will ensure that the event queue is processed at each iteration of the loop when DRAWNOW is called. An example of how to use DRAWNOW is shown below:
for i = 1:10000
j = i^2;
drawnow;
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by