Ctrl-C in Matlab R2023b not working well

14 ビュー (過去 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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by