Shut down Matlab and open new Matlab instance
조회 수: 3 (최근 30일)
이전 댓글 표시
I want to close the current Matlab instance and open the new Matlab instance through Matlab command or script...Any inputs??
댓글 수: 0
답변 (3개)
Srinivas
2014년 3월 6일
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
Srinivas
2014년 3월 10일
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
Andreas Goser
2014년 3월 6일
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
Sean de Wolski
2014년 3월 10일
@Andreas, I assume you need to have the '&' after 'matlab' otherwise it will hold closing the first session until the second has closed.
Sean de Wolski
2014년 3월 10일
system('matlab &');exit
댓글 수: 5
AA
2018년 2월 6일
Hello @per,
Is there a way to do it on Linux? I tried the above command, it shows the startup screen but does not launch a new window?
Thanks!
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!