How to force matlab to save before exit?

조회 수: 5 (최근 30일)
ahmed shaaban
ahmed shaaban 2014년 5월 25일
댓글: ahmed shaaban 2014년 5월 27일
Hello all I am using matlab via server, so I quit MatLab several times before remembering to save. Is there is any way to fore MatLab to save the file code every several minutes. Or method to enforce MatLab to ask for save before quit .
  댓글 수: 2
Jan
Jan 2014년 5월 25일
What exactly is "the file code"? Do you mean the contents of the base workspace, the files opened in the editor or some specific files?
ahmed shaaban
ahmed shaaban 2014년 5월 27일
I mean that file in the editor .

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2014년 5월 27일
Inside of your finish.m file, you can save the files using the editor api.
files = matlab.desktop.editor.getAll;
save(files)
  댓글 수: 1
ahmed shaaban
ahmed shaaban 2014년 5월 27일
thanks a lot, it works very good. this saves all in my matlab editor.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2014년 5월 25일
You should take a look at the help for quit and exit - there it is described that if you have a .m-file finish.m it will run before quiting - so in such a file you can have automatic save commands or something even more elaborate. You might also be interested in the diary function - I start every matlab session with:
diary(fullfile('/home','bjorn','MatlabRuns',[datestr(clock,30) '.txt']))
That way all my commandline activity is saved away. (Got this trick from someone else...)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by