automatically delete .m files when exit MATLAB

조회 수: 5 (최근 30일)
feng junya
feng junya 2016년 3월 1일
댓글: Misun Kim 2018년 10월 6일
I edit .m files in my laptop, upload them onto a work computer and open them on the work computer. When I exit MATLAB, these files are deleted automatically with out any warning. Only the files uploaded from a remote computer meet this problem, while those files created locally not. How can I fix it?

답변 (3개)

Jan
Jan 2016년 3월 1일
It is unlikely, that Matlab deletes files. And it is hard to believe, that Matlab decides, which files are deleted, according to the way they have been created. Whenever such a magic behavior occurres, there have been real and clear reasons, but the user has not recognized them yet.
So please look in the file finish.m if it contains any strange code which deletes M-files. How do you upload the files? Can you confirm, that the files are really really really deleted when Matlab exits? What happens, if you upload the files and restart the machine without staring Matlab?
Where are the files saved? On a local disk or in a network? Check the logs of the virus scanner.
  댓글 수: 1
feng junya
feng junya 2016년 3월 2일
Thanks Jan Simon.
I agree that there no any magic thing and there must be something I have missed. The Matlab version is 2014b.
I tried to find out under what condition the files are deleted when exit Matlab and failed. It seems that such a phenomenon is independent of the way a file is created, copied from a remote computer or another local directory. When I copied files into the current path of Matlab when Matlab is open, these files sometimes removed when exited Matlab.
As you said, Matlab do not know how a file is created, but it can find when a file is edited. I think Matlab treated the files I copied as temporary saved files and remove them when exit.

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


Jos (10584)
Jos (10584) 2016년 3월 2일
Could this be related to the back-up files that can be automatically created and deleted when you edit them? Take a look at your settings for the editor/debugger.

Misun Kim
Misun Kim 2018년 10월 6일
I experienced the same problem and I could replicate the problem sometimes (but not always).
1. Create a matlab script from my laptop- "machine A"(e.g. C:Directory1/testScript.m) Version: MATLAB2014a, Windows10 pro - Surface Book.
2. Open a remote desktop for other Window PC-"machine B" (MATLAB2014a, Windows8.1 Enterprise)
3. Copy and paste the script (by pressing ctrl+CV) to the local directory of machine B, (e.g. D:/Experiment1/testScript.m)
3. Edit the script in the remote desktop (machine B).
4. Close the MATLAB in machine B. Then MATLAB will ask whether you want to save the change. Click yes.
5. Sometimes, the edited script (testScript.m) in machine B is instantly and permanently deleted when MATLAB closes (as if .asv files).
As Feng Junya and Jos suggested, I think it is related to autosave file and unknown bug with file transfer in Windows remote desktop. I have not yet tested the 'disable MATLAB default setup for deleting autosave file when MATLAB is closed'. It is even more frustrating because this problem happens only occasionally. It would be easier to discover the bug and fix the problem if I can replicate every time. It is very scary and frustrating that it can happen. (I already lost my important script)
I hope this issue can be resolved soon Any advice will be greatly appreciated!
  댓글 수: 1
Misun Kim
Misun Kim 2018년 10월 6일
It might not be the m-file autosave issue, rather more complicated temporary file issues. I copied multiple m-files into the local directory of remote desktop PC, and opened only one of the file in the MATLAB and then closed the MATLAB. All the m-files that were copied together are deleted together!!! I disabled "Automatically delete autosave files" option, and it didn't solve the problem.

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by