How can I implement a function that does the equivalent of Ctrl-C?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 27 Jun. 2009
Kommentiert: Walter Roberson
am 18 Dez. 2018
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.
Akzeptierte Antwort
MathWorks Support Team
am 25 Aug. 2015
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 Kommentare
Adam
am 3 Aug. 2016
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
am 18 Dez. 2018
error() with an empty string is aa special case that does not trigger an error . Historically it was used internally in Mathworks code.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!