How to recover corrupted *.mat file data

I have 2 *.mat files that each have one table in them. MATLAB keeps telling me they both might be corrupt. I'm not sure why, but my only guess is different people having them open/saving them at the same time? How can I recover the data?
What I've tried:
  1. Shutdown computer and restart in case it's a memory issue
  2. splitmat corruptMATFileName (splitmat isn't recognized) (https://www.mathworks.com/matlabcentral/answers/98890-how-do-i-recover-data-from-a-corrupt-mat-file)
  3. used loadfixnames(): link. ( Error compiling loadfixnames.c )
  4. type(corruptMATFileName). Just produced garbage. (https://www.mathworks.com/matlabcentral/answers/1998783-error-using-load-input-must-be-a-mat-file-or-an-ascii-file-containing-numeric-data-with-same-numbe)
The files are attached. Is the data just lost or is there anything else I can do?

 Accepted Answer

Unfortunately those files are not in .mat format and cannot be recovered.
Both files start with the same sequence of 8 bytes, but those does not match any known "magic numbers"

7 Comments

Okay I'll just go cry in the corner then :(
Do you have any insight as to what causes corruption? It's just a log that is written/appended/saved every time a user uses a MATLAB app I created to track their activity and usage of the app. I occasionally open the logs to check on things. Could me opening them be causing the corruption?
Update: I was actually able to recover the files through the windows "Previous Versions" option, no need for me to cry haha. Still curious about how to avoid corruption in the future though.
Good thing you had Previous Versions turned on!
"I occasionally open the logs to check on things. Could me opening them be causing the corruption? ... Still curious about how to avoid corruption in the future though."
I can't say how mat-file writing works, but general advice is:
When you want to check the logs, make a copy of the log file and check on things in the copy. Don't open the original, since that may cause problems with other processes accessing it. When you are done checking, delete the copy.
What ‘previous versions’ utility are you referring to?
Is there a link or other reference?
@Voss Yep that sounds like the smart thing to do. I'll do that in the future to avoid any problems. Thanks!
@Star Strider This link describes what I'm talking about. I'm on a company computer, so I think my company set it up in a way that allows us to access previous versions of files, but maybe this is something that can be done on personal computers as well?
Thank you!
It would definitely be comforting to have a utility like that! I’ve never heard of it before, and couldn’t find it on an Interweb search. (I keep SD card backups of my important files, however that’s just on my computers.)

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!