Old .m files don't display code

10 ビュー (過去 30 日間)
Bruckus
Bruckus 2014 年 7 月 3 日
回答済み: RECAI YILMAZ 2023 年 11 月 10 日
This one is a real puzzle and has cost me 2 days of slog already.
I used an earlier version of Matlab for a project some 6-7 years ago and wrote a substantial amount of code. I organised the code into a main folder on my hard disk, containing about half of the code. The remaining .m scripts and .mat files I functionally organised into sub-folders. Over the years I've kept the code on several external hard drives and copied it from one to another, maybe two or three times altogether.
Now I've a project that requires me to re-use that old code. In the main folder all the .m files still show as having information inside (file size is several KB), but they don't display anything in Matlab, nor in a text editor, nor in WordPad. In contrast, all the .m files in the sub-folders work perfectly.
I've found a data recovery tool that shows there is still information inside the .m files in the main folder, but I can't extract it.
Any suggestion on how to tackle this and get the code out of the .m files is much appreciated!
  3 件のコメント
John D'Errico
John D'Errico 2014 年 7 月 3 日
編集済み: John D'Errico 2014 年 7 月 3 日
They are probably corrupted. You DO have a backup, right? Or has the backup also been corrupted? It happens to all of us.
Joseph Cheng
Joseph Cheng 2014 年 7 月 3 日
編集済み: Joseph Cheng 2014 年 7 月 3 日
When you look (open in text editor and matlab) is there anything in there? i know it doesn't display anything but there may be things in there. what i mean 14000 spaces can be 13Kb. special characters? it does sound like it is completely corrupted as nothing shows up.

サインインしてコメントする。

回答 (4 件)

Jan
Jan 2014 年 7 月 3 日
M-files are text files. If you cannot see the contents in the editor, the characters have been overwritten by spaces, zeros or other special characters. You can open the files in Matlab and check, which values are found inside, but without any doubt, the original contents of the files is lost. You cannot reconstruct them. So John's idea is the only way out: Recreate them from a backup.

Bruckus
Bruckus 2014 年 7 月 4 日
Thanks all. I have a backup on CD, but it contains only a small part of the missing data. What I find hard to grasp is how the files in the main folder could be corrupted, but those in the sub-directories are all fine.
@ Joseph: Nothing gets displayed in Matlab or notepad/wordpad, no zeros, nothing. When I copy the 'phantom' data to Word and manipulate the formating nothing happens. I suspect that some might be recoverable, because in one data recovery tool the preview (of the file contents) window showed HEX and ASCII contents. Unfortunately this tool was pre-viewing only.

CARLOS ALBERTO
CARLOS ALBERTO 2022 年 6 月 17 日
Jan,
Recreate them from a back up? Back up we do not re-create, we open. And this for amost everything I know in computation, including the Mathematica files I worked with, and other statistics software I used.
Definetely, not expected. We work we programed codes, advancing over it day by day. If, instead, when we go to our yesterday file and find out none of the programed codes. Then, we are working with something that is for a day only, or else for a task without closing the computer or files daily.

RECAI YILMAZ
RECAI YILMAZ 2023 年 11 月 10 日
I had the same issue on Matlab 2023b. The issue is resolved when I copied the files (literally ctrl c and ctrl v at the same directory). To copy them, it needed admin priviledges. Maybe what is blocking Matlab to display them was not having the admin permission.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by