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 Center および File ExchangeIntroduction 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