How can I implement a function that does the equivalent of Ctrl-C?

13 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日
コメント済み: Walter Roberson 2018 年 12 月 18 日
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
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
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
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 ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by