When I use matlab to run the program, I am afraid that my hands are cheap. I click the X in the upper right corner and accidentally close the program. I will lose the results after running for many days. Can matlab have a prompt dialog box when exiting like other programs? ? The answer is, yes! And different versions. The new version, such as the 2022a I am currently using, can be set in the settings, and the lower version needs to write the code by itself.
1 High version matlab - setting
The higher version settings are relatively simple, and can be realized directly through the settings.
Homepage—>Preset—>Confirmation dialog box—>Check “Confirm before exiting matlab” on the right
2 Low version matlab - code
Create a new .m file, copy and paste the following code, save it as a finish.m file, and store it in a custom path, such as "D:\workspace"
button = questdlg('真的要退出?再学会儿嘛~~~','play or not','我要去玩耍','再学会儿','再学会儿');
switch button
case '我要去玩耍',
disp('Exiting MATLAB');
case '再学会儿',
quit cancel;
otherwise
quit canc