why does "save -append" work so slow and increase the size of mat file for simple replacement?
13 views (last 30 days)
Show older comments
Hi,
I am in this situation for couple of times but have no clue. I can understand that when there are structures in my data, saving may take long time due to decompression. However, what confused me is that, even when I replace the existing structures only, without creating any new elements, the updated mat file increased a lot. It looks like the old structures are not erased at all. Could anyone help me out here? Thanks a lot.
0 Comments
Answers (2)
Benjamin Avants
on 15 May 2014
If you use the -append option, save will not overwrite any of your existing data. It will simply add the new data into the existing file. This can/will duplicate variables and structures already stored in the file.
If you want to change some of the values and not others, you should open the file and load the existing data. Then change the values you want to change in the imported data before overwriting the old file with the modified data. This is faster than appending an existing file and you don't get duplicate entries.
If you have the full data set in memory that you wish to save, simply overwrite the existing file with the data in memory. This would be the fastest way if it is possible in your code.
See Also
Categories
Find more on Workspace Variables and MAT-Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!