Problem to open a matlab file, empty code.

52 次查看(过去 30 天)
Hey guys,
I have a big question, moreover, a big problem and i hope that you save me.
I spent the last week working in a Matlab project and today, before to turn down my computer, i save the file.
Ok, a few hours later, when i open the Matlab, guess what? My code was clean, completely empty, without any character.
I try open the file in other computer and it was the same problem, the octave online and sublime text show a big amount of zeros.
I check the file and your length is around 3KB, what suggests that isn't empty.
I really don't know what to do, if you have any suggestion, please tell me.
Thanks
  1 个评论
Walter Roberson
Walter Roberson 2019-10-26
编辑:Walter Roberson 2019-10-26
I suspect you accidently used "save" naming your .m file . That would have saved the content of your workspace over top of the .m file, destroying the .m file.
If so, then the file is gone and probably cannot be recovered. You can look for a .asv (autosave) or .m~ (also autosave but for Mac or Linux) file, but if you do not have those then you will need to go into any system backups or source code control system you might have.
Always use regular backups, even as a student. You should run backups according to the maximum amount of work that you are willing to lose. For example if it would be okay to lose one day of work, then back up at least twice a day -- twice because one of the backups might not work for whatever reasons.

请先登录,再进行评论。

回答(3 个)

CARLOS ALBERTO
CARLOS ALBERTO 2022-6-17
I have had the same problem, and I use the save option for a .mat file.
I don´t think I miss anything, since the file even opens the variables a created, but the codes are not shown in the main page. Only a blank sheet.
Right the opposite to Mathematica: it opens the codes, the programing, while the created variable you must re-run for activating them again. But that was easy. It just takes Ctrl+Shift over each steps of the codes.
  2 个评论
Ibrahim A. Hameed
Ibrahim A. Hameed 2022-10-29
I have the same problems where all my m.files from the last 10 years are not working at all. All are empty.
Walter Roberson
Walter Roberson 2022-10-29
I had a bunch of my MATLAB code content disappear over a year ago. For me the problem had to do with a corrupted filesystem on my MacOS system -- the fault was MacOS not MATLAB for me.

请先登录,再进行评论。


Mehran Ahmadlou
Mehran Ahmadlou 2023-1-28
I have the same issue with MATLAB 2022b! And I beleive it's nothing to do from our side, but it's a malab bug! All the mfiles out of sudden became blank, empty!
  2 个评论
Mehran Ahmadlou
Mehran Ahmadlou 2023-1-28
I just installed R2021a and all the mfiles are fine.
Frederike Petzschner
Same issue I tried 3 versions of matlab and all m files appear empty. If I open the same m file on another computer the full content is still there. What is the bug and how can I solve it?

请先登录,再进行评论。


Wade
Wade 2023-3-30
Hi,
I have a similar problem. I saved file in MATLAB figure. After opening I got the graphs but no codes. Is it permanent code loss?
Regards,
Matti
  1 个评论
Walter Roberson
Walter Roberson 2023-3-30
If you saved something on top of a .m or .mlx file, then it is a permanent loss unless you can find an auto-save as described in https://www.mathworks.com/matlabcentral/answers/487598-problem-to-open-a-matlab-file-empty-code#comment_760406 . You should be sure to configure system backups for any work like this.

请先登录,再进行评论。

类别

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