save with "'-append" on table increase file size without modification of the variable

조회 수: 8 (최근 30일)
I create a table of 100x100, then save it:
t = array2table(rand(100));
save('table.mat', 't')
The file weight 76 Ko. Then, without changing t, I re-save it with append:
save('table.mat', 't', '-append')
The file now weight 152Ko (76*2), and it will add 76Ko each time I append the same table.
If you load the table, it's the same than the original one:
s = load('table.mat', 't');
setdiff(s.t, t) % It's empty
The documentation do say "save(filename,variables,"-append") adds new variables to an existing file. If a variable already exists in a MAT-file, then save overwrites it with the value in the workspace.", but the size of the MAT-File increase by the size of the table each time.
What is happening with the -append option ?
  댓글 수: 4
Walter Roberson
Walter Roberson 2024년 8월 30일
save -append works by first appending the new data to the .mat file, and then going back through the .mat file and marking previous versions of the variable as being unused.
Arthur Roué
Arthur Roué 2024년 9월 3일
Thanks all for your replies, I missed out the existing threads.
@Madheswaran provides a link to the bug report, this issue can be close.

댓글을 달려면 로그인하십시오.

채택된 답변

Madheswaran
Madheswaran 2024년 9월 3일
Hello,
The behaviour you are encountering is a known issue. When saving certain MATLAB data types—like tabular classes, strings, and non-fundamental types—using the ‘-append’ flag, the MAT-file size can increase with each save operation. This is a documented bug, and you can find more details in the MathWorks bug report here:
The report also provides two ways to work around this issue. Please refer to the link for more information.
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by