Ctrl-C in Matlab R2023b not working well
12 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!