MATLAB Answers


appending variables in save causing file corruption

Asked by Oliver Warlow on 29 Aug 2019
I have some .mat files containing several variables of type 'Table'. I perform some analysis and replace some of these variables using the command
save('FileName', {'VarX', 'VarY', etc}, 'mat', '-append')
In this case there are other variables in the file appart from VarX and VarY which I am not overwriting. this seems to work most of the time, but every now and again i get an error:
Error using save
Error closing file 'FileName'
The file may be corrupt.
The files I am dealing with are around 250-500MB in size.
Any ideas why this might happen? It means I then corrupt my original data which is annoying. Perhaps I am best to create a totally new file with the new data and then replace the old file, therefore if I do get a corrupt file when writing I won't have destroyed my original data.


Sign in to comment.


0 Answers