Problem to open a matlab file, empty code.
조회 수: 17 (최근 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
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.
답변 (4개)
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
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
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
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
Frederike Petzschner
2024년 8월 16일
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
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
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.
Hardy
2025년 6월 2일
I have had the same problem twice, the first time was with 2023b version and the 2nd time is with 2024b and it just happened today. Both times, by the time that I noticed the Matlab source code does run (it does nothing), the source code window becomes blank, the OS .m files and the .m backup files has 0 KB in size. Both times, there is no warnings -- probably the code was wiped out the day before.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!