Matlab terminates the running program

There are generally three ways to terminate the program that Matlab is running.

  • hot key
  • Close the Matlab program
  • Add code to the script

1. Shortcut keys

Ctrl+C
Ctrl+break
Ctrl+Alt+break
If it is the code running on the server, after pressing the shortcut key, sometimes it takes a short time before the program stops.

2. Close the Matlab program

Sometimes the memory usage of Matlab is too high and there will be a crash. At this time, you can close the Matlab optimization program. To close Matlab, you can click x, or Ctlr+Alt+Delete, start the task manager and force it to close.

3. Add code

code meaning
quit Terminate the MATLAB program. The quit function does not automatically save the workspace.
quit cancel Applicable to finish.m script, it can be canceled and exited. It is invalid elsewhere.
quit force Bypass finish.m and terminate MATLAB. When the finish script does not allow you to exit, you can use this syntax to overwrite the script.
quit(code) Return the specified value as the MATLAB exit code.
quit(code,“force”) Bypass finish.m and terminate MATLAB, returning the exit code at the same time.
return Programmatically stop the execution of a function or script before it reaches the end

Example: quit(0,"force")

Guess you like

Origin blog.csdn.net/Gou_Hailong/article/details/113242160