automatically delete .m files when exit MATLAB

8 visualizaciones (últimos 30 días)
feng junya
feng junya el 1 de Mzo. de 2016
Comentada: Misun Kim el 6 de Oct. de 2018
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?

Respuestas (3)

Jan
Jan el 1 de Mzo. de 2016
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 comentario
feng junya
feng junya el 2 de Mzo. de 2016
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.

Iniciar sesión para comentar.


Jos (10584)
Jos (10584) el 2 de Mzo. de 2016
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 el 6 de Oct. de 2018
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 comentario
Misun Kim
Misun Kim el 6 de Oct. de 2018
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by