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
MathWorks Support Team 2009년 9월 1일
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