Ctrl-C in Matlab R2023b not working well

조회 수: 12 (최근 30일)
Jim Svensson
Jim Svensson 2024년 3월 11일
댓글: Jim Svensson 2024년 3월 25일
When running Matlab in Window the keyboard combination Ctrl-C has previously worked well to abort execution of a running matlab program/script/function, and to return to the command window.
In Matlab R2023b this does not work well in several cases. Some specific cases include
  • Iterating over multipel matlab.unittest.TestCase tests.
  • Iterating in loops calling linprog() solvers.
Overall it seems that in loops and similar iterations Ctrl-C does not work well to abort the current execution.
Question: Is the how it is supposed to be now? Is there something that can be configured to make it work better as before?
Version R2022b does not have this issue. I don't know about R2023a.

답변 (1개)

Vandit
Vandit 2024년 3월 22일
Hello Jim,
As mentioned in the MATLAB documentation Stop Execution - MATLAB & Simulink (mathworks.com), Ctrl+C might not always effectively stop execution for scripts or functions that run for an extended duration or that call built-ins or MEX-files. This is due to the potential risk of leaving MATLAB in an inconsistent state or not properly releasing native resources, like memory, which are shared with MEX files within the same memory space as MATLAB.
To mitigate this issue and enhance the interruptibility of your MATLAB scripts or functions, it is recommended to incorporate a "drawnow", "pause", or "getframe" function within your file, especially if it contains large loops. These functions can provide MATLAB with the opportunity to process the interrupt request more effectively.
To know more about "drawnow", "pause" and "getframe" functions, please refer to the links given below:
Hope this helps.
  댓글 수: 1
Jim Svensson
Jim Svensson 2024년 3월 25일
Thanks for the suggestion. I will add some of those calls and see if it helps.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by