Data lost in saved file
Ältere Kommentare anzeigen
I have a code which periodically saves many .mat files. e.g.:
save( filename, 'P_hist', 'O_hist', 'Osums_hist' ...
, 'ttrack_hist', 'CLa_hist', 'CSm_hist', 'CYb_hist');
and each file is about 200MB. However, when I attempt to access the data, about 95% are normal: the matrices exist in a structure. But, for about 5% of the files, all the data is gone and replaced by a single matrix with one value like 48000 or 30000, or something. But the file size is still 200MB, so the file seems corrupted somehow.
Does anyone know what is happening? And is there a way to prevent it and/or recover the data?
3 Kommentare
Guillaume
am 8 Dez. 2014
Your first assumption in cases like this shouldn't be "the files are corrupted" but "there's a bug in my code".
Can you show the loop you use to save the files.
Christopher
am 10 Dez. 2014
Bearbeitet: per isakson
am 10 Dez. 2014
If it were a hardware / corruption issue, a corrupted file would be unreadable rather than just be read partially. Actually, I just tried: changed one byte in a .mat file, matlab crashes trying to read it!.
So, things to check in order:
- Are you reading the file correctly?
- Copy it onto another machine and read it there?
- Are the input to the code the same on the machine that fails?
- Is matlab the same on the machine that fails?
Antworten (0)
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!