Shut down Matlab and open new Matlab instance

8 views (last 30 days)
I want to close the current Matlab instance and open the new Matlab instance through Matlab command or script...Any inputs??

Answers (3)

Srinivas
Srinivas on 6 Mar 2014
something like this
Curr_dir = pwd;
bat_str = ['"' matlabroot '\bin\matlab.exe' '"'];
fid = fopen('restart_matlab.bat','w');
fprintf(fid, '%s\n', ['cd ' Curr_dir]);
fprintf(fid, '\n%s', bat_str);
fclose(fid);
system('restart_matlab.bat')
exit
HTH
  2 Comments
Srinivas
Srinivas on 10 Mar 2014
just delete the bat file
Curr_dir = pwd;
bat_str = ['"' matlabroot '\bin\matlab.exe' '"'];
fid = fopen('restart_matlab.bat','w');
fprintf(fid, '%s\n', ['cd ' Curr_dir]);
fprintf(fid, '\n%s', bat_str);
fclose(fid);
system('restart_matlab.bat')
delete('restart_matlab.bat')
exit

Sign in to comment.


Andreas Goser
Andreas Goser on 6 Mar 2014
In a release a couple of years ago, I created a "finish.m" on the path and within the file it was just "matlab".
When closing MATLAB, with would run finish.m and while closing MATLAB it would start another one.
  4 Comments
Andreas Goser
Andreas Goser on 10 Mar 2014
Maybe... I haven't tried. This is what I did probably 8y ago ;-)

Sign in to comment.


Sean de Wolski
Sean de Wolski on 10 Mar 2014
system('matlab &');exit
  5 Comments

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!