How can I implement a function that does the equivalent of Ctrl-C?
13 次查看(过去 30 天)
显示 更早的评论
I would like a command that does the equivalent of Ctrl-C so that I can programmatically quit out of my code. This would expecially be useful as a callback to a pushbutton.
采纳的回答
MathWorks Support Team
2015-8-25
There is no way to programmatically issue a Ctrl-C in MATLAB besides using the keyboard's Ctrl-C combination.
As an alternative, you can use the ERROR command to force an error that will exit the code. For example:
error('Program terminated for a specific reason')
2 个评论
Adam
2016-8-3
error( ... ) should always return you to the command line unless you have a try-catch statement which handles the error, in which case it will continue.
Walter Roberson
2018-12-18
error() with an empty string is aa special case that does not trigger an error . Historically it was used internally in Mathworks code.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!