quit
August 12th, 2009 Posted in Functions
quit Quit MATLAB session.
quit terminates MATLAB after running the script FINISH.M,
if it exists. The workspace information will not be saved
unless FINISH.M calls SAVE. If an error occurs while
executing FINISH.M, quitting is cancelled.
quit FORCE can be used to bypass an errant FINISH.M that
will not let you quit.
quit CANCEL can be used in FINISH.M to cancel quitting.
It has no effect anywhere else.
Example
Put the following lines of code in your FINISH.M file to
display a dialog that allows you to cancel quitting.
1 2 3 4 5 6 7 8 9 10 | button = questdlg('Ready to quit?', ... 'Exit Dialog','Yes','No','No'); switch button case 'Yes', disp('Exiting MATLAB'); %Save variables to matlab.mat save case 'No', quit cancel; end |
Note: When using Handle Graphics in FINISH.M make sure to use UIWAIT, WAITFOR, or DRAWNOW so that figures are visible.
Related posts
Leave a Reply
You must be logged in to post a comment.