Data lost in saved file

2 ビュー (過去 30 日間)
Christopher
Christopher 2014 年 12 月 8 日
編集済み: Guillaume 2014 年 12 月 11 日
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 件のコメント
Christopher
Christopher 2014 年 12 月 10 日
編集済み: per isakson 2014 年 12 月 10 日
Well, if I have a 200MB .mat file and matlab can only see a single 1 by 1 matrix on one file out of 20 (the other 19 having the expected variables), all generated with identical code, I don't think it is entirely the codes fault. The save command is implemented in a loop as:
% DATA DUMP
if sstep==ddumpstep
dumpnum = dumpnum+1;
filename = [savefilename num2str(dumpnum)];
if Udiff==1
save( filename, 'A', 'B', 'C', 'D', 'E', 'F', 'G' ...
, 'H', 'I', 'J', 'K', 'L');
elseif REEdiff==1
save(filename, 'A', 'B', 'C', 'D', 'E', 'F', 'G');
else
save(filename, 'A', 'B', 'C', 'D');
end
sstep = 0;
end
I have run a new batch of codes and the problem has reappeared in [edit] multiple instances. I suspect some kind of weird data writing problem, but it's weird.
It also only seems to occur on one of my computers. Data generated from my other computers seems to not suffer the same problem.
Guillaume
Guillaume 2014 年 12 月 11 日
編集済み: Guillaume 2014 年 12 月 11 日
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?

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

回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by