MATLAB: How to implement a function that does the equivalent of Ctrl-C

breakccontrolctrl-cexecutionexitflagMATLABprogramprogrammaticprogrammaticallyquitroutinestopterminate

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.

Best Answer

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')